3

我有一个使用 jquery mobile 的骨干应用程序。我正在尝试使用弹出对话框,但是问题是当我单击链接#popupSuccess 时,它不会激活模式,因为我认为主干正在捕获它。有任何想法吗?

这是我的模态代码

<a class="modalLink" id="modalSuccessTrigger" href="#popupSuccess" data-rel="popup" data-position-to="window" data-role="button" data-inline="true" data-transition="pop" data-icon="delete" data-theme="b">Success</a>

<div data-role="popup" id="popupSuccess" data-overlay-theme="a" data-theme="c" data-dismissible="false" style="max-width:400px;" class="ui-corner-all modalLinkCont">
    <div data-role="header" data-theme="a" class="ui-corner-top">
        <h1>Correct!</h1>
    </div>
    <div data-role="content" data-theme="d" class="ui-corner-bottom ui-content" style="background-color:white">
        <h3 class="ui-title">That is correct. Tap to continue to level 2</h3>
        <a href="#" data-role="button" data-inline="true" data-rel="back" data-transition="flow" data-theme="b">Contineu</a>
    </div>
</div>
4

2 回答 2

4

您需要以编程方式启动弹出窗口:

在您的主干视图中:

events: {
   'click #modalSuccessTrigger': 'openPopUp'
},

openPopUp: function(e) {
   e.preventDefault()
   $('#modalSuccessTrigger').popup('open')
}

有关更多详细信息,请参阅文档:http: //jquerymobile.com/demos/1.2.0-alpha.1/docs/pages/popup/index.html

于 2013-03-18T09:33:26.720 回答
0

为了处理这个问题,我使用来阻止主干路由并激活标记为的链接的弹出处理data-rel="popup"

$(document).ready(function(){
  ($('a[data-rel="popup"]')).on('click', function(event) {
    event.preventDefault();
    event.stopImmediatePropagation();
    var target = $(this).attr("href");
    $(target).popup('open');
  });
});
于 2013-12-21T17:46:39.030 回答