JQuery Mobile .page()函数导致无限循环? [英] JQuery Mobile .page() function causes infinite loop?

查看:161
本文介绍了JQuery Mobile .page()函数导致无限循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用来自AJAX响应的数据动态创建列表视图。它成功地创建了listview并填充它,但是当我在它上面调用JQM的.page()函数时,它似乎进入了一个无限循环,其中listview被永久地附加。

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.

这是JQM中的错误还是我做错了什么?

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是一个允许我在JQM加载时运行页面级脚本的函数。它在基本模板或index.html中定义:

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);
        };


推荐答案

而不是使用 .page ()使用 .trigger(create);
jQuery移动团队更新:7月18日周 http://jquerymobile.com/blog/

这篇关于JQuery Mobile .page()函数导致无限循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆