页面初始化后添加jQuery Mobile的渲染与内容问题 [英] jQuery Mobile rendering problems with content being added after the page is initialized

查看:122
本文介绍了页面初始化后添加jQuery Mobile的渲染与内容问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jQuery Mobile和骨干JS的一个项目。这主要是工作,使用jQuery Mobile的事件pagebeforeshow触发正确的骨干视图。在骨干网查看该特定jQuery Mobile的页面,这就是它做所有需要的动态的东西。有些事情的看法做的是使用下划线的模板系统在某些位拉。

I'm using jQuery Mobile and Backbone JS for a project. It's mostly working, using jQuery Mobile's event 'pagebeforeshow' to trigger the correct Backbone View. In the Backbone View for that particular jQuery Mobile page, that's where it's doing all the dynamic things needed. Some of the things the views do is pull in certain bits using Underscore's templating system.

这是所有伟大的,直到我在这里使用模板系统在形式上位拉。例如,一组动态的单选按钮(其是从骨干集合生成)。这些单选按钮我想起来样式使用的是什么jQuery Mobile的所提供的。目前,jQuery Mobile的不捡这些动态插入单选按钮。我只需调用jQuery Mobile的小工具滑块()方法再次做滑块时pviously解决了这个问题$ P $,它似乎刷新它们......这似乎并不符合这些单选按钮的情况。

This is all great until where I pulling in form bits using the templating system. For example, a set of dynamic radio buttons (which are generated from a Backbone Collection). These radio buttons I want to style up using what jQuery Mobile has to offer. At the moment, jQuery Mobile is not picking up these dynamically injected radio buttons. I solved this issue previously when doing sliders by just calling the jQuery Mobile widget "slider()" method again and it seemed to refresh them... This doesn't seem to be the case with these radio buttons.

在骨干视图,我试着再次调用小部件的方法:

In the Backbone View, I tried calling the widget methods again:

$(this.el).find("input[type='radio']").checkboxradio();
$(this.el).find(":jqmData(role='controlgroup')").controlgroup();

我尝试过其他的方式太左右,但它似乎我需要做的是这样的分组造型工作等,但这个只是看起来不正确! ......这样也造成了错误,当我点击了单选按钮,说:不能叫上初始化checkboxradio以前的方法,试图调用方法'刷新'。

I tried them the other way around too, but it seemed I need to do it this way for the grouping styling to work etc. But this just doesn't seem right! ...doing this also caused errors when I clicked on the radio buttons, saying: "cannot call methods on checkboxradio prior to initialization; attempted to call method 'refresh'"?

这似乎应该有jQuery Mobile的方式来重新初始化页面什么的?我注意到有源$ C ​​$ C一个页面窗口小部件。

It seems there should be a way in jQuery Mobile to re-initialize the page or something?! I noticed there is a 'page' widget in the source code.

如何jQuery的移动手柄形式/元件被注入到DOM的页面作出后?是否有处理它如何弥补了形式干净的方式?必须有呼吁的形式来渲染的jQuery Mobile的方式,而不只是依赖于数据属性标签的基本HTML的干净的方式?

How does jQuery Mobile handle forms/elements being injected into the DOM after the page is made? Is there a clean way of handling how it makes up the forms? There must be a clean way of calling on the forms to render 'the jQuery Mobile way' without it just relying on data attribute tags in the base HTML?

任何帮助或洞察到这一问题将大大AP preciated ......我对这个任务的试图让骨干JS和jQuery Mobile的很好地协同工作非常多。

Any help or insight into this problem would be greatly appreciated... I'm very much on this quest of trying to get Backbone JS and jQuery Mobile to work nicely together.

非常感谢,詹姆斯

推荐答案

更新

由于jQueryMobile Beta2中有做这个的事件。 .trigger('创造')元素上造成里面的一切它被正确地绘制。

Since jQueryMobile beta2 there is an event to do this. .trigger('create') on an element to cause everything inside it to be painted correctly.

另外一个问题,是不是重复,而是需要一个answet我贴过10次:)

Another question that is not a duplicate, but requires an answet I posted over 10 times :)

[老答案]

尝试。第()

更多在我的常见问题的详细信息:
http://jquerymobiledictionary.pl/faq.html

More details in my faq: http://jquerymobiledictionary.pl/faq.html

这篇关于页面初始化后添加jQuery Mobile的渲染与内容问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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