6

1.9.1 minPhoneGap で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>

それらでaction1を押すとshowDetails()、メソッドが呼び出されますが、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>

私に何ができる?

4

6 に答える 6

11

私の解決策

$.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");
};
于 2014-03-22T21:17:09.657 に答える
3

回避策として、この単純な関数を使用しました。

function myPopup(myPage) {
    history.back();
    setTimeout(function () {
        $(myPage).popup('open');
    }, 100);
}
于 2014-08-30T22:00:12.873 に答える
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")
于 2014-09-30T14:56:32.307 に答える
1

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

function switchpop()
{
    $( '#popupMenu' ).popup( 'close' );  
    $( "#popupMenu" ).bind({popupafterclose: function(event, ui) 
            { 
                $( "#notes" ).popup( "open" );
            }
            });                
}
于 2014-08-15T20:26:20.237 に答える
1

ポップアップの連鎖はできないようです。

ソリューション:

$( document ).on( "pageinit", function() {
    $( '.popupParent' ).on({
        popupafterclose: function() {
            setTimeout( function(){ $( '.popupChild' ).popup( 'open' ) }, 100 );
        }
    });
});
于 2013-08-25T14:25:10.887 に答える
0

これと4時間格闘した後、問題を次のように減らしました。

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

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

    window.setTimeout(function () { $('#popupContact').popup('open') }, 50);
于 2014-09-24T13:45:01.313 に答える