简体   繁体   English

JQuery Mobile:无法从选择菜单中打开弹出窗口

[英]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. 我试图从jquery移动选择菜单打开一个弹出对话框。 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 popupDelete div看起来像这样

<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. 我不能使用上面的,因为如果客户端处理命令的速度很慢,它将无法在1000毫秒内工作,我不想增加它以便为更快的客户端做出不合理的延迟。 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毫秒的延迟?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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