我有一个带有这个页面init事件函数的页面。
$("#myPage").live('pageinit', function ()
{
// here is some irrelevant parsing code
console.log("myHTMLStr: "+myHTMLStr);
$('#result_content').html(myHTMLStr);
}这个div:<div id="result_content"></div>
无论我如何到达页面,console.log的结果总是一样的。但是,当我从前一个页面进入页面时(通过类似于$.mobile.changePage(MyPage, { transition: 'none', reverse: false });的内容,result_content div中填充了myHTMLStr的内容。但是当我从下一个屏幕到达时,使用back按钮,实现如下所示:
<a data-role="button" href="MyPage.html" data-icon="arrow-l" data-iconpos="left"
class="ui-btn-left" data-transition="none">
MyPage
</a>div元素result_content未填充。是否可能.html()函数不起作用?还会发生什么??
更新
我在jquery.Mobile1.3.0中使用jquery-1.8.2。Android上的测试(三星Galaxy SII)
发布于 2013-10-14 14:11:16
由于DOM中重复的id‘,代码无法工作。对元素使用唯一的id,无论您使用的是单页模板还是多页模板.
参考资料:http://dev.w3.org/html5/markup/global-attributes.html#common.attrs.id
https://stackoverflow.com/questions/19357213
复制相似问题