admin管理员组文章数量:1241157
I'm dynamically creating a listview with data from a AJAX response. It successfully creates the listview and populates it, but when i call JQM's .page() function on it, it seemingly goes into an infinite loop where the listview is appended forever.
Is this a bug in JQM or am I doing something wrong?
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 is a function that allows me to run page-level scripts when they are loaded by JQM. It's defined in the base template or index.html:
function pageScript(func) {
var $context = $("div:jqmData(role='page'):last");
func($context);
};
I'm dynamically creating a listview with data from a AJAX response. It successfully creates the listview and populates it, but when i call JQM's .page() function on it, it seemingly goes into an infinite loop where the listview is appended forever.
Is this a bug in JQM or am I doing something wrong?
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 is a function that allows me to run page-level scripts when they are loaded by JQM. It's defined in the base template or index.html:
function pageScript(func) {
var $context = $("div:jqmData(role='page'):last");
func($context);
};
Share
Improve this question
asked Jul 8, 2011 at 12:50
sw00sw00
9802 gold badges16 silver badges30 bronze badges
2
- 1 .page() refreshes the page with jQM markup – Phill Pafford Commented Jul 8, 2011 at 14:57
- it appears that you can't selectively use .page() on individual elements. it runs on "page" level and subsequently triggers the "pagecreate" event. – sw00 Commented Jul 12, 2011 at 12:40
1 Answer
Reset to default 14Instead of using .page()
use .trigger( "create" );
jQuery Mobile team update: Week of July 18th http://jquerymobile./blog/
本文标签: javascriptJQuery Mobile page() function causes infinite loopStack Overflow
版权声明:本文标题:javascript - JQuery Mobile .page() function causes infinite loop? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740100759a2224452.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论