【问题标题】:typeerror result of expression $(this).simpledialog [undefined] is not a function表达式 $(this).simpledialog [undefined] 的 typeerror 结果不是函数
【发布时间】:2013-05-10 07:06:31
【问题描述】:

我正在关注http://dev.jtsage.com/jQM-SimpleDialog/demos/string.html 链接以使用 jquery mobile 创建对话框 我在我的 html 中定义了以下内容

 <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 不是函数。 我做错了什么?..

【问题讨论】:

    标签: jquery jquery-mobile cordova simpledialog


    【解决方案1】:

    我希望你已经初始化了 jQM-SimpleDialog js 文件,因为这是一个 3rd 方对话框实现,在经典的 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');
        });        
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-19
      • 1970-01-01
      • 2011-09-28
      • 1970-01-01
      • 1970-01-01
      • 2010-10-10
      相关资源
      最近更新 更多