2013-05-10 119 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'); 
    });   
}); 
相关问题