2013-08-25 13 views
6

私はPhoneGapでjQueryモバイル1.9.1 minを使用しています。
は、私は、クリック上の各ITENアクションポップアップが開き、リストを持っている:jQueryモバイルポップアップからのポップアップ

function showActions(index){ 
    selectedIndex = index; 
    $("#actionPopup").popup("open", {positionTo: '#list li:nth-child('+ index +')'}); 
} 
<div data-role="popup" id="actionPopup" data-overlay-theme="a"> 
    <a href="#" data-rel="back" data-role="button" data-theme="a" data-icon="delete" data-iconpos="notext" class="ui-btn-right">Close</a> 
     <ul data-role="listview"> 
       <li data-role="divider">Actions</li> 
       <li data-icon="false" onclick="showDetails();">action1</li> 
       <li data-icon="false">action2</li> 
       <li data-icon="false">action3</li> 
       <li data-icon="false">action4</li> 
      </ul> 
     </div> 

私はと呼ばれる彼らは、メソッドshowDetails()でアクション1で押したが、2番目のポップアップが表示されていません。

function showDetails(){ 
    console.log("showDetails"); 
    $("#infoPopup").popup("open"); 
} 
<div data-role="popup" id="infoPopup"> 
      <a href="#" data-rel="back" data-role="button" data-theme="a" data-icon="delete" data-iconpos="notext" class="ui-btn-right">Close</a> 
      <div id="infoContent"> 
       <table> 
        <tr id="eventcode"> 
         <td>test1:</td> 
         <td>&nbsp;</td> 
        </tr> 
        <tr id="eventtype"> 
         <td>test2:</td> 
         <td>&nbsp;</td> 
        </tr> 
       </table> 
      </div> 
     </div> 

私は何ができますか?

答えて

10

私のソリューション

$.mobile.switchPopup = function(sourceElement, destinationElement, onswitched) { 
    var afterClose = function() { 
     destinationElement.popup("open"); 
     sourceElement.off("popupafterclose", afterClose); 

     if (onswitched && typeof onswitched === "function"){ 
      onswitched(); 
     } 
    }; 

    sourceElement.on("popupafterclose", afterClose); 
    sourceElement.popup("close"); 
}; 
1

連鎖ポップアップがpossibleではないようです。

ソリューション:

$(document).on("pageinit", function() { 
    $('.popupParent').on({ 
     popupafterclose: function() { 
      setTimeout(function(){ $('.popupChild').popup('open') }, 100); 
     } 
    }); 
}); 
1

私はそれが正常に動作し、ポップアップからポップアップを切り替えるには、このコードを使用していました。

function switchpop() 
{ 
    $('#popupMenu').popup('close'); 
    $("#popupMenu").bind({popupafterclose: function(event, ui) 
      { 
       $("#notes").popup("open"); 
      } 
      });     
} 
3

私は回避策については、この簡単な関数を使用:私はこれまでの問題を低減し、このと戦うの4時間後

function myPopup(myPage) { 
    history.back(); 
    setTimeout(function() { 
     $(myPage).popup('open'); 
    }, 100); 
} 
0

を:

これは、ボタンのクリック機能であります最初のポップアップで

$('#popupCall').popup('close'); 

    window.setTimeout(function() { $('#popupContact').popup('open') }, 50); 
3

@Rakooは良い答えがあります。ここでスリムバージョンは次のとおりです。

$.mobile.switchPopup = function(sourceElement, destinationElement, onswitched) { 
    sourceElement.one("popupafterclose", function() { 
     destinationElement.popup("open") 
     !onswitched || typeof onswitched !== "function" || onswitched() 
    }).popup("close") 
}; 

あなたがonswitched機能を必要としないと$ .mobileに追加されていない場合、それはこの短いと単純なことができます:

$('#popup1').one("popupafterclose", function(){$('#popup2').popup("open")}).popup("close") 
関連する問題