2013-05-10 114 views
0

我下面的鏈接http://dev.jtsage.com/jQM-SimpleDialog/demos/string.html使用jQuery Mobile的 創建對話框我已經定義在我的HTML以下類型錯誤的結果(這).simpledialog [未定義]是不是一個函數

<div data-role="popup" id="Savepopup" class="ui-corner-all" style="background: url(Image/PopupBackground.png); background-size: 100% 100%;background-repeat: no-repeat;"> 
    <div id="datalink"> 
     <a href="#" data-inline="true" data-rel="dialog" ><img src="Image/Button.png" width="100%" height="" ></a> 
    </div> 
    </div> 

and in js file i have defined the following 



$(document).delegate('#datalink', 'click', function() { 
    $(this).simpledialog({ 
    'mode' : 'string', 
    'prompt' : 'What do you say?', 
    'buttons' : { 
     'OK': { 
     click: function() { 
     // var name = text($('#datalink').attr('data-string')); 
      //console.log("name name "+name); 
      alert("data was entered"); 
     } 
     }, 
     'Cancel': { 
     click: function() { }, 
     icon: "delete", 
     theme: "c" 
     } 
    } 
    }); 
}); 

但當我點擊按鈕打開對話框時,我得到錯誤說$(this).simpledialog不是一個函數。 什麼是我在做什麼?..

回答

0

的錯誤,我希望你已經初始化jQM-SimpleDialog js文件,因爲這是一個第三方的對話框實現,這裏面不能一個經典的jQuery Mobile框架中找到。

如果您只需要使用基本對話框,那麼我會建議您使用正常的jQM dialog

基本上你的錯誤是說simpledialog函數無法找到,那是因爲它沒有被初始化。

我給你做的工作示例經典JQM對話框:http://jsfiddle.net/Gajotres/Jx9xM/

$(document).on('pageinit', '#mainPage', function(){ 
    $(document).on ('click','#createEvent', function() {   
     $.mobile.changePage('#addCatForm', { 
      transition: 'pop', 
      changeHash: true, 
      role: 'dialog' 
     }); 
    }); 

    $(document).on('click','#canCat',function() { 
     $('#addCatForm').dialog('close'); 
    });   
}); 
相關問題