jQuery Mobile站点中所有页面通用的弹出窗口 [英] Popups common to all pages in jQuery Mobile site

查看:125
本文介绍了jQuery Mobile站点中所有页面通用的弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用jQuery Mobile制作一个网站。它由HTML文件中的许多页面组成,其中一些页面只有一个页面,其中一些页面有几个页面(使用它们的多页面功能)。

该网站将会有一些弹出窗口通知,他们将在所有页面上看起来相同。我正在使用他们的新弹出窗口功能,这似乎是为此目的而设计的。我可以通过在每个页面上放置弹出窗口的副本来轻松实现这一点,但这会产生很多冗余的代码,这些代码很难维护。我可以让我的服务器在适当的位置为我插入代码,但这看起来很复杂且效率不高。



我试图在页面之外放置弹出窗口,可靠地工作(您可以在此处看到一个示例)。



我试图通过使用模板系统(内置于underscore.js中的模板)动态生成它们,但看起来可能会导致问题 - 我将不得不在销毁每个弹出框时关闭以避免内存泄漏。 / p>

我不确定这是否是弹出窗口小部件中的错误,这可能是因为弹出窗口小部件仅在jQuery Mobile的alpha版本中。



有没有人对如何在多个html文件中创建包含多个页面的网站有任何想法,以及所有页面都有的一些弹出窗口?

解决方案

我在jQuery Mobile上看到了您的请求g ithub,并发布了我在我的Web应用程序上使用的解决方案。检查 http://ghita.org/jquery/dynamic-mobile-popup 这是一个很小的插件,允许您拥有动态弹出窗口,它可让您专注于弹出窗口的内容事件



包含插件( 1.8kb ),然后调用:

  $。dynamicPopup({content:'这是弹出窗口的动态内容。')); 

内容 - 可以是字符串或jQuery html对象。 p>

请查看 https://github.com/serbanghita / jQM-dynamic-popup ,其中一些选项是从jQuery的移动popup()函数继承而来。



这个问题是一个展示因为我有动态的网页,我不喜欢手动注入HTML内容以使popup()处于活动状态。希望你找到它有帮助。


I am trying to make a site using jQuery Mobile. It consists of many pages in HTML files, some of which have only one page, and some of which have several pages (using their multi-page feature).

The site is going to have some popups for notifications, and they are going to look the same on all pages. I am implementing the popups using their new popup feature which seems designed for this purpose. I can easily implement this by putting copies of the popups on each of the pages but this will create a lot of redundant code which may be hard to maintain. I can probably make my server insert the code for me in the proper places but that seems complex and inefficient.

I tried putting the popups outside of the pages and they do not work reliably (you can see an example here).

I tried dynamically generating them by using a templating system (the one built into underscore.js) but that looks like it may cause problems – I will have to destroy every popup when it is closed to avoid memory leaks.

I am not sure if this is a bug in the popup widget, which seems likely since the popup widget is only in an alpha version of jQuery Mobile.

Does anyone here have any ideas as to how to make a site with many pages in several html files, with a few popups that are common to all of the pages?

解决方案

I've seen your request on jQuery Mobile github, and posted a solution that I'm using on my web applications. Check http://ghita.org/jquery/dynamic-mobile-popup it's a small plugin that allows you to have dynamic popups, it let you focus on the content of the popup and the events.

Include the plugin (has 1.8kb), and then call:

$.dynamicPopup({content: 'This is the dynamic content of the popup.'});

content - can be a string or a jQuery html object.

Check https://github.com/serbanghita/jQM-dynamic-popup for the full list of options, some of which are inherited from jQuery's mobile popup() function.

This problem was a show stopper for me because I have dynamic webpages and I don't care of manually injecting HTML content for the popup() to be active. Hope you find it helpful.

这篇关于jQuery Mobile站点中所有页面通用的弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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