Jquery Mobile 1.4.1 动态标头 [英] Jquery Mobile 1.4.1 dynamic header
问题描述
我正在尝试在 jquery mobile 1.4.1 中动态附加我的标头 (date-role=header
).我在它的右侧添加了一个按钮,我正在使用 $('#page').trigger('pagecreate')
以便使用新按钮重新创建标题并具有jquery 移动样式.这在 jquery mobile 1.3.2 中有效,但在 1.4.1 中无效.我用新的 enhanceWithin()
函数尝试了它,但它仍然不起作用.我也试过 $('#header').enhanceWithin()
,但也没有用.我知道 trigger('create')
方法已被弃用,但我似乎无法弄清楚如何让它与新的 enhanceWithin()
函数一起使用>
I'm trying to append my header (date-role=header
) dynamically in jquery mobile 1.4.1. I'm adding a button to the right side of it and I'm using $('#page').trigger('pagecreate')
so that the header is recreated with the new button and has the jquery mobile styling. This worked in jquery mobile 1.3.2, but does not work in 1.4.1. I tried it with the new enhanceWithin()
function and it still does not work. I also tried $('#header').enhanceWithin()
and that did not work either. I understand the trigger('create')
method has been deprecated, but I cannot seem to figure out how to get this to work with the new enhanceWithin()
function
推荐答案
jQuery Mobile 1.4 中插入工具栏的方式不同,.toolbar()
函数应该在动态插入的页眉/页脚上调用.
The way to insert toolbars in jQuery Mobile 1.4 is different, .toolbar()
function should be called on header/footer inserted dynamically.
$("[data-role=header], [data-role=footer]").toolbar();
然后,当工具栏向页面添加填充导致页面滚动时,应重置页面的高度.
And then, page's height should be reset as toolbars add padding to page causing page to scroll.
$.mobile.resetActivePageHeight();
.trigger("pagecreate")
和 .trigger("create")
已弃用并替换为 .enhanceWithin()
.应该在包含动态添加元素的 parent div 上调用新函数.
The .trigger("pagecreate")
and .trigger("create")
are deprecated and replaced with .enhanceWithin()
. The new function should be called on parent div containing the dynamically add elements.
这篇关于Jquery Mobile 1.4.1 动态标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!