简体   繁体   中英

JQuery Mobile: can't open a popup from a select menu

I am trying to open a popup dialog box from a jquery mobile select menu. If I put the popup open command in a timeout it works, but not when directly opening the popup. ie:

This works:

 $("#message-commands").bind("change", function (event, ui) {
    var value = event.target.value;
    switch (value) {
        case "delete":
            setTimeout(function () {
                $('#popupDelete').popup('open');
            }, 1000);
            break;
    }

But this does not:

$("#message-commands").bind("change", function (event, ui) {
    var value = event.target.value;
    switch (value) {
        case "delete":
            $('#popupDelete').popup('open');
            break;
    }

The popupDelete div looks like this

<div data-role="popup" id="popupDelete" style="max-width:300px;" class="ui-corner-all ui-popup ui-body-c ui-overlay-shadow" aria-disabled="false" data-disabled="false" data-shadow="true" data-corners="true" data-transition="none" data-position-to="origin">
    <div data-role="header" class="ui-corner-top ui-header ui-bar-a" role="banner">
            <h1 class="ui-title" role="heading" aria-level="1">Delete?</h1>

    </div>
    <div data-role="content" data-theme="d" class="ui-corner-bottom ui-content ui-body-d" role="main">
            <h3 class="ui-title">Are you sure you want to delete this message?</h3>

        <p>This action cannot be undone.</p>    <a href="#" data-role="button" data-inline="true" data-rel="back" data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" class="ui-btn ui-shadow ui-btn-corner-all ui-btn-inline ui-btn-up-c"><span class="ui-btn-inner ui-btn-corner-all" onclick="$('#deleteConfirm').popup('close');"><span class="ui-btn-text">Cancel</span></span></a>   <a href="#" data-role="button" data-inline="true" data-rel="back" data-transition="flow" data-theme="b" data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" class="ui-btn ui-shadow ui-btn-corner-all ui-btn-inline ui-btn-up-b" onclick="deleteConfirmed();"><span class="ui-btn-inner ui-btn-corner-all"><span class="ui-btn-text">Delete</span></span></a> 
    </div>
</div>

Any suggestions? I can't use the above, because if a client is slow to process the command, it will not work within the 1000ms, and I don't want to increase it to make an unreasonable delay for faster clients. I suspect the issue is that the select menu must close first before it can open a popup, but there's no event to detect if a select menu has closed.

似乎是,打开一个弹出窗口需要一些延迟, 也见这个例子 ,但为什么你不只是使用100毫秒而不是1000毫秒的延迟?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM