Jquery Mobile 1.4.1动态头 [英] Jquery Mobile 1.4.1 dynamic header

查看:116
本文介绍了Jquery Mobile 1.4.1动态头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在jquery mobile 1.4.1中动态添加标题( date-role = header )。我在它的右边添加一个按钮,我使用 $('#page')。trigger('pagecreate'),以便重新创建标题与新的按钮和有jquery移动造型。这工作在jquery mobile 1.3.2,但不工作在1.4.1。我试着用新的 enhancementWithin()函数,它仍然不工作。我也试过 $('#header')。enhanceWithin(),也没有工作。我理解触发器('create')方法已被弃用,但我似乎不知道如何让这个工作与新的 enhancementWithin () function

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();

然后,页面的高度应该重置为工具栏添加填充到页面,导致页面滚动。 p>

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()。新函数应在包含动态添加元素的父元素 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屋!

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