简体   繁体   English

如何使用jQuery mobile的data-theme属性制作主题切换器

[英]how to make a theme switcher using the jQuery mobile's data-theme attribute

I want to make a theme switcher using the data-theme attribute of the jQuery mobile framework. 我想使用jQuery移动框架的data-theme属性创建一个主题切换器。 When the user clicks a link which has a data-theme inside it, all my pages' data-theme attribute should be replaced with this clicked data-theme attribute. 当用户单击其中包含数据主题的链接时,应使用此单击的data-theme属性替换我的所有页面的data-theme data-theme属性。 To get a better idea of what I'm trying to do see this page at the jQuery mobile site, it's pretty close to what I'm trying to do for my pages except that it only updates the current page, and I want to update all of the webApp pages. 为了更好地了解我正在尝试做什么, 在jQuery移动网站上看到这个页面,它非常接近我正在尝试为我的页面做的事情,除了它只更新当前页面,我想要更新所有的webApp页面。

Have you looked at jquery ui theme roller?, it's available for Jquery Mobile too 你看过jquery ui theme roller吗?它也适用于Jquery Mobile

http://jquerymobile.com/themeroller/ http://jquerymobile.com/themeroller/

generate a set of themes and switch it accordingly. 生成一组主题并相应地切换它。 Here's a link on switching: http://midnightprogrammer.net/post/Change-Page-Themes-Dynamically-Using-JQuery-Theme-Roller.aspx 这是关于切换的链接: http//midnightprogrammer.net/post/Change-Page-Themes-Dynamically-Using-JQuery-Theme-Roller.aspx

You can set data-theme="THEME_LETTER" as a php variable. 您可以将data-theme =“THEME_LETTER”设置为php变量。 Then, have links on the page to switch themes. 然后,在页面上有链接切换主题。 When the user clicks a link for theme "b", it will set a session variable, and then on each page load, the THEME_LETTER will be set by php to reflect their selection. 当用户单击主题“b”的链接时,它将设置会话变量,然后在每个页面加载时,将由php设置THEME_LETTER以反映其选择。

inside the HTML, it would look like this: 在HTML中,它看起来像这样:

data-theme=" <?php echo $_SESSION['THEME_LETTER']; ?> " data-theme =“ <?php echo $_SESSION['THEME_LETTER']; ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM