簡體   English   中英

如何從第一個彈出窗口打開第二個jquery-mobile彈出窗口

[英]How can I open a second jquery-mobile popup from the first popup

使用jquery-mobile我試圖在用戶單擊刪除時從第一個彈出窗口打開第二個彈出窗口(確認)。

我在這里看到了一個與jsfiddle代碼http://jsfiddle.net/EWQ6n/520/類似的線程: 在JQuery Mobile的Dialog中打開Dialog

但是,即使將此工作彈出代碼復制並粘貼到我的jsfiddle中也行不通。 我正在使用jQuery 1.10.1和1.4.2移動版。 上面的線程中的工作jsfiddle使用1.9。 與移動1.30b.1 當我將我的jquery更改為舊版本時,它的工作原理。 (我知道,這似乎是一個簡單的答案,但現在改變將搞亂其他代碼依賴和樣式。我想了解這個問題。)

    <!-- first popup -->
<div data-role="popup" id="popupInfo" data-dismissible="false" style="max-width:400px;">
    <div data-role="header" class="ui-corner-top">
         <h1>Contact Info</h1>
    </div>
    <div data-role="content" data-theme="a">
        <label for="name">Name:</label>
        <input type="text" name="name" id="name" value="" placeholder="Display name" data-theme="a">
        <label for="tel">Number:</label>
        <input type="tel" name="tel" id="tel" value="" placeholder="tel" data-theme="a">
        <button type="submit" data-theme="b" class=" ui-btn ui-btn-b ui-shadow ui-corner-all">OK</button> <a href="#" data-role="button" data-rel="back">Cancel</a>
<a href="#popupDelete" data-role="button" data-rel="popup" data-transition="flow" data-icon="minus">Delete</a>
    </div>
</div>

<!-- second popup -->        
<div data-role="popup" id="popupDelete" data-overlay-theme="a" data-theme="c" data-dismissible="false" style="max-width:600px;">
    <div data-role="header" data-theme="aa" class="ui-corner-top">
         <h1>Delete Contact?</h1>

    </div>
    <div data-role="content" data-theme="dd">
         <h3 class="ui-title">Are you sure you want to delete <span>#</span> from your contacts?</h3>

        <p>This action cannot be undone.</p>
        <button type="submit" data-theme="b" class=" ui-btn ui-btn-b ui-shadow ui-corner-all ui-btn-inline">OK</button> <a href="#" data-role="button" data-rel="back">Cancel</a>

    </div>
</div>

我也注意到在jsfiddle中,我的第一個彈出代碼中的最后2個div是紅色的。 (這是否意味着它們無效?)在我的編輯器中,它們看起來似乎是有效的HTML - 至少我找不到任何問題。

這是我的非工作jsfiddle: http//jsfiddle.net/gmdavis62/7AuNC/2/

感謝@ezanker,我有一個解決方案。 在其他帖子的popup api鏈接之后,我發現了一個不涉及插件的簡單解決方案。

$(document).on("pageinit", function () {
  $('#del').click(function (e) { // e is the event
    setTimeout(function () {
        $("#popupDelete").popup("open")
    }, 100);
  });
});

我有一個jsfiddle來演示這個。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM