2011-09-01 31 views
5

我试图在jQuery Mobile中创建对话框,当您单击Google Maps标记时出现对话框。以编程方式在jQuery Mobile中加载对话框?

示例网址:http://cyclestreets.darkgreener.com/location/(滚动到伦敦,英国的位置查看标记)。

我有一部分的方式出现,与此代码:

google.maps.event.addListener(map_marker, 'click', function() { 
    $.mobile.changePage({ url: $("#photo"), data: "id=" + marker.id, type: "GET"}, 'pop', false, true); 
}); 

但是,一些问题与造型和数据做:

  1. 出现的对话框是全屏幕。有什么办法可以使它成为部分屏幕,like the default jQuery Mobile dialogs,并且像About和Prefs对话框on my home page
  2. 标题中没有关闭链接 - 这也是there is in the default jQuery mobile dialog。我能确保这一点出现,而不是手动添加它吗?
  3. 在对话框的.live()事件中,我如何获取传递给它的数据?
+0

我加入'$( “#照片”)固定的前两项对话框({的AutoOpen:假});'文档加载,第三个这个问题后:HTTP://计算器.com/questions/7272174/jquery-flow-of-events - 我看不到一个答案链接,将其添加为答案。 – Richard

回答

1

由于beta 1,得到div出现的对话框中,使用data-role="dialog"属性上div而不是data-role="page"

5
function openPopup(element_id) 
{ 
    $.mobile.changePage(element_id, { transition: "pop", role: "dialog", reverse: false }); 
} 
0

请注意,jquery对话框要求存在数据角色内容和标题div以便适当地应用样式。这将为您提供标题中关闭按钮的完整对话框。

<div data-role="dialog" id="dialog" > 
<div data-role="header"><h3>Oops!</h3></div> 
<div data-role="content"> 
    <p>You done screwed up, partner!</p> 
</div> 

</div> 
+0

我有同样的问题,我做了JT说的,但关闭按钮不起作用。 –

相关问题