我是 jquery 移动框架工作的新手。据我观察,我无法在文档的第一页上触发 pagebeforeshow 事件
有人遇到过同样的问题吗?请建议我触发事件的步骤或任何其他替代方案
demo http://jsfiddle.net/yNzzG/ http://jsfiddle.net/yNzzG/
在演示中,您将看到警报pagebeforeshow
处理程序将被触发。
其余代码会说清楚,希望有帮助,
code
$(document).bind('mobileinit', function() {
alert('mobileinit');
});
$(function() {
var selector = ':jqmData(role=page)';
$('body').on('pageinit', selector, function(e, data) {
// initialize page
var $page = $(this);
alert('init ' + $page.attr('id'));
}).on('pagebeforeshow', selector, function(e, data) {
// showpage
var $page = $(this);
alert('show Page before Show Stuff == > ' + $page.attr('id'));
});
$('#page1').on('pageinit', function(e, data) {
// setup handler
var $page = $(this);
$page.find('.colorchanger').click(function() {
var $content = $page.find('.ui-content'),
isBodyC = $content.hasClass('ui-body-c');
$content.toggleClass('ui-body-c', !isBodyC).toggleClass('ui-body-e', isBodyC);
});
});
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)