如何让jQuery Mobile Magic在"pageshow"页面中正常工作事件处理程序? (JQM 1.1.0) [英] How to get jQuery mobile magic to work in "pageshow" event handler? (JQM 1.1.0)

查看:97
本文介绍了如何让jQuery Mobile Magic在"pageshow"页面中正常工作事件处理程序? (JQM 1.1.0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,在"pageshow"事件中将ICanHaz.js模板插入到jQuery移动文档中时遇到问题. HTML可以很好地插入DOM中并可以正常显示,但是没有应用任何jQuery Mobile UI类.以下代码是coffeescript:

Hey I'm having a problem with inserting an ICanHaz.js template into a jquery mobile doc on the 'pageshow' event. The HTML inserts into the DOM fine and displays fine, but none of the jQuery Mobile UI classes are applied etc. The following code is coffeescript:

    $('#trailRewards').live 'pageshow', (event, ui) =>
        html = ich.t_reward_list()
        $(html).trigger('create')
        $('#trailRewards').html(html)

我是在错误的时间调用创建"事件,还是我触发了错误的事件?

Am I calling the 'create' event at the wrong time, or am I triggering the wrong event?

如果html中已经存在html,而我只是使用常规的jquery选择器来更新它可以工作的部分内容,但是当然我不能使用令人讨厌的模板了!

If the html is already in the div and I just use regular jquery selectors to update bits of content it works, but then of course I can't use templates which is annoying!

干杯:)

固定错别字

推荐答案

我最终通过使用"pagebeforecreate"事件找到了最佳解决方案.请参阅此处以获取更多信息: http://jquerymobile.com/test/docs/api/events .html

I ended up finding out the best solution by using the "pagebeforecreate" event instead. See here for more info: http://jquerymobile.com/test/docs/api/events.html

    $('#trailRewards').live 'pagebeforecreate', (event, ui) =>
        html = ich.t_reward_list()
        $(html).trigger('create')
        $('#trailRewards').html(html)

希望能帮助与我有同样问题的人:)

Hope that helps someone who has the same issue as me :)

这篇关于如何让jQuery Mobile Magic在"pageshow"页面中正常工作事件处理程序? (JQM 1.1.0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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