我正在尝试使用 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 Pane 中没有硬编码页脚)
关于jQuery 移动数据页 ='content' 仅转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8794542/