jQuery mobile data-page =’content’仅限转换

前端之家收集整理的这篇文章主要介绍了jQuery mobile data-page =’content’仅限转换前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用PhoneGap和jQuery Mobile开发iPhone应用程序.这个程序有一个固定页脚.

我现在面临的主要问题是内置页面转换会改变整页,要求我在每个页面中复制/粘贴页脚代码.

显然,这不是这样做的方法.页脚的任何小变化都必须重复10次(10页).

我的问题如下:如何只加载页面的“内容”部分(使用幻灯片转换),所以我不必在我的所有页面中都有代码

解决方法

jQuery Mobile尚未提供该功能.您可以在iOS 5设备上打开“真实”固定页脚和固定页眉的touchOverflowEnabled选项,但不能打开任何其他设备.

In order to achieve true fixed toolbars,a browser needs to either
support position:fixed or overflow:auto. Fortunately,this support is
coming to mobile platforms so we can achieve this with web standards.
In jQuery Mobile,we have added a global feature called
touchOverflowEnabled that leverages the overflow:auto CSS property on
supported platforms like iOS5. When enabled,the framework wraps each
page in a container with it’s own internal scrolling. This allows us
to position the toolbars outside the scrolling body so they truly stay
fixed in place at all times.

资料来源:http://jquerymobile.com/demos/1.0/docs/toolbars/bars-fixed.html

但是,您可以在程序化庄园中设置页脚,而不是对每个页面进行硬编码:

//bind an event handler to the `pagecreate` event for all `data-role="page"` elements
$(document).delegate('[data-role="page"]','pagecreate',function () {

    //append a footer to this page (`pagecreate` is only called once per page added to the DOM so you don't have to worry about appending multiple footers to a single page
    $(this).append('<div data-id="my-fixed-footer" data-position="fixed" data-role="footer">{THE HTML FOR YOUR FOOTER GOES HERE}</div>');
});

这是一个演示:http://jsfiddle.net/vNqaG/(注意HTML窗格中没有硬编码的页脚)

猜你在找的jQuery相关文章