2011-09-01 51 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說的,但關閉按鈕不起作用。 –

相關問題