2011-10-06 30 views
0

是否可以在同一頁面內使用內聯內容創建jQuery Mobile dialog從內聯內容的對話可能嗎?

例如:

<div data-role="page"> 
    <div data-role="content"> 

     <!-- this causes the entire current page to load as the dialog --> 
     <a href="#modal" data-rel="dialog">Open Dialog<a> 

     <div id="modal" style="display: none"> 
      Hello World 
     </div> 

    </div> 
</div> 

典型的對話框要求鏈接對象的href是一個單獨的「網頁」,或者一個沿着側位於當前頁的:

<div data-role="page"> 
    <div data-role="content"> 
     <a href="#modal" data-rel="dialog">Open Dialog<a> 
    </div> 
</div> 
<div data-role="page" id="modal"> 
    <div data-role="content"> 
     Hello World 
    </div> 
</div> 

但是,我的模板結構禁止我將鏈接與模態內容分開。如果可能,我想將事物模塊化成一個可插拔的控件。使用我目前的CMS框架(Sitecore)爲模態內容創建一個全新的外部頁面會很麻煩。

+0

你有沒有找到任何解決辦法? – Nachiket

+0

Nachiket找到答案 –

回答

1

jQueryMobile - SimpleDialog2允許內嵌的對話 http://dev.jtsage.com/jQM-SimpleDialog/demos2/

<a href="#" id="opendialog" data-role="button">Open Dialog</a> 


    <div id="inlinecontent" style="display:none" data-options='{"mode":"blank","headerText":"Yo","headerClose":true,"blankContent":true}'> 

<ul data-role='listview'><li>Some</li><li>List</li><li>Items</li></ul> 
<a rel='close' data-role='button' href='#'>Close</a> 
</div> 

$(document).delegate('#opendialog', 'click', function() { 
// NOTE: The selector is the hidden DIV element. 
$('#inlinecontent').simpledialog2(); 
}) 
相關問題