jquery-mobile:Object[Object-Object]没有方法';jqmData';

jquery-mobile:Object[Object-Object]没有方法';jqmData';,jquery-mobile,ibm-mobilefirst,Jquery Mobile,Ibm Mobilefirst,我对Jquery和jQueryMobile比较陌生,我只是尝试在页面上添加加载动画,我只是简单地遵循其中一个演示中提供的代码。然而,我得到以下错误 Uncaught TypeError: Object [object Object] has no method 'jqmData' 我正在使用以下代码片段和javascript <button class="show-page-loading-msg ui-btn-right" data-icon="refresh" data-theme

我对Jquery和jQueryMobile比较陌生,我只是尝试在页面上添加加载动画,我只是简单地遵循其中一个演示中提供的代码。然而,我得到以下错误

Uncaught TypeError: Object [object Object] has no method 'jqmData' 
我正在使用以下代码片段和javascript

<button class="show-page-loading-msg ui-btn-right" data-icon="refresh" data-theme="d" data-textonly="false" data-textvisible="true" data-msgtext="Loading..." data-inline="true">Refresh</button>

<script>
window.$ = window.jQuery = WLJQ;
$( document ).on( "click", ".show-page-loading-msg", function() {
var $this = $( this ),
    theme = $this.jqmData( "theme" ) || $.mobile.loader.prototype.options.theme,
    msgText = $this.jqmData( "msgtext" ) || $.mobile.loader.prototype.options.text,
    textVisible = $this.jqmData( "textvisible" ) || $.mobile.loader.prototype.options.textVisible,
    textonly = !!$this.jqmData( "textonly" );
    html = $this.jqmData( "html" ) || "";
$.mobile.loading( "show", {
        text: msgText,
        textVisible: textVisible,
        theme: theme,
        textonly: textonly,
        html: html
});

setTimeout(WL.Client.reloadApp, 5000);
$.mobile.loading( "hide" );
});

</script>
刷新
window.$=window.jQuery=WLJQ;
$(文档)。在(“单击“,”。显示页面加载消息”,函数(){
变量$this=$(this),
theme=$this.jqmData(“theme”)|$.mobile.loader.prototype.options.theme,
msgText=$this.jqmData(“msgText”)|$.mobile.loader.prototype.options.text,
textVisible=$this.jqmData(“textVisible”)| |$.mobile.loader.prototype.options.textVisible,
textonly=!!$this.jqmData(“textonly”);
html=$this.jqmData(“html”)| |“”;
$.mobile.load(“显示”{
文本:msgText,
textVisible:textVisible,
主题:主题,,
textonly:textonly,
html:html
});
setTimeout(WL.Client.reloadApp,5000);
$.mobile.load(“隐藏”);
});
错误指向javascript
theme=$this.jqmData(“theme”)

当我在浏览器控制台上调试时,我能够看到分配给$this变量的按钮数据值
如果您运行以下操作,请给出建议:

console.log($.mobile.version);
。。。然后检查控制台。它打印出版本了吗?还是说它没有定义

如果未定义,请检查是否正确引用了jQuery和jQuery移动库,如下所示:

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css">
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>

尝试将脚本放入“mobileinit”事件处理程序(或页面事件处理程序),如: window.$=window.jQuery=WLJQ; $(document).on('mobileinit',function(){ //你的剧本 });
注意脚本的顺序

您好,感谢您的回复,这是我目前参考的
啊,尝试使用jquery 1.9.1版(这是与jquery Mobile 1.3.1一起使用的版本)。简化的JSFIDLE在这里-这是否仍然不起作用:(.我在worklight server上运行它,您认为这可能与此有关吗?您好,我不知道。如果这不是在内部网上某个没有访问internet的地方运行,请尝试从远程位置引用库(如所贴)。如果您不能做到这一点,并且至少jQuery mobile的其余部分正在工作,那么您可以通过调用$this.attr(“数据主题”)来获取数据主题属性;但我怀疑如果jqmData不起作用,这是否会起作用。此外,请尝试抓取整个html页面并创建JSFIDLE或使用完整的html文件更新您的帖子。嘿,感谢您的输入,在JFIDLE中进行测试时,我注意到,如果我删除脚本开头的这一行,
window.$=window.jQuery=WLJQ;
,它工作得很好在JFIDLE中,我在我的代码中测试了相同的代码,消除了错误,但是我没有看到加载程序,但是接下来要重新加载页面的行执行fine也有助于理解Worklight版本是什么……嘿,感谢您的输入,这个
窗口。$=window.jQuery=WLJQ;
只是用来指向worklight我是对的,所以如果我在脚本中使用我自己的Jquery verison,我可以忽略这一行而不产生任何影响吗?是的,我认为您可以删除这一行并尝试以下方法:
window.$=WLJQ;window.jq=Jquery.noConflict();(函数($){//your script})(jq);
<script src="js/jquery-2.0.3.js"></script> <script> window.$ = window.jQuery = WLJQ; $(document).on('mobileinit', function() { // your script }); </script> <script src="jqueryMobile/jquery.mobile-1.3.1.js"></script>