Tag: dhtml

JQuery Mobile .page()函数导致无限循环?

我正在使用来自AJAX响应的数据动态创建列表视图。 它成功创建了listview并填充它,但是当我在其上调用JQM的.page()函数时,它似乎进入了一个无限循环,其中listview永远被追加。 这是JQM中的错误还是我做错了什么? pageScript(function($context){ $context.bind(“pagecreate”, function(event, ui){ createMenu(); //function that deletes existing ul#menu and dynamically creates new one. $(‘ul#menu’).page(); //here’s where it causes a problem $(‘#menu a’).bind(‘click’, function(){ $.mobile.changePage($(this).attr(“href”), {pageContainer: $(“#primary-content”), transition: “fade”, changeHash: false, reloadPage: true}); return false; }); }); }); pageScript是一个允许我在JQM加载时运行页面级脚本的函数。 它在基本模板或index.html中定义: function pageScript(func) { var $context = $(“div:jqmData(role=’page’):last”); func($context); };