页面更改时动态更改标题按钮图标,jQuery mobile 1.4.5
Dynamically change header button icon on page change, jQuery mobile 1.4.5
好吧,这应该很简单,但似乎什么都不起作用。。。
<div data-role="header" data-position="fixed" data-tap-toggle="false">
<h1 class="ui-title" id="headertitle"></h1>
<a class="ui-btn-left ui-nodisc-icon ui-btn-inline ui-mini" id="leftButton" onclick="alert('this');" data-icon="gear" data-iconpos="notext"></a>
</div>
我在jQuery mobile的页面更改上尝试了以下页面显示、页面创建和页面显示前事件:
$('#leftButton').data("icon", "grid");
$('#leftButton').jqmData("icon", "grid");
$('#leftButton').attr("data-icon", "grid");
这些似乎都不起作用。那么,如何更改标题按钮图标以适应每一页呢?
<a id="leftButton" href="#" class="ui-btn ui-icon-gear ui-btn-icon-notext ui-corner-all">No text</a>
$( "#leftButton" ).on("click", function(){
$(this).removeClass("ui-icon-gear").addClass("ui-icon-grid");
});
如果你想使用一个小部件,那么你可以在代码中设置图标选项(http://api.jquerymobile.com/button/#option-图标):
<input id="btnWidget" type="button" data-icon="gear" data-iconpos="notext" value="Icon only" />
$( "#btnWidget" ).on("click", function(){
$(this).button( "option", "icon", "grid" );
});
这是两种技术的DEMO
相关文章:
- 无法从jquery Mobile导航栏重定向到另一个页面
- jquery mobile上多个页面上的一个表单
- window.location使用jquery mobile实现chrome跳转
- 防止jQuery Mobile中的ajax缓存
- 如何在JQUERY Mobile上放置谷歌地图
- JQuery Mobile Javascript复杂方程式
- jQuery Mobile Undefined不是一个函数
- jQuery mobile not going through ID
- 如何使用javascript或jquery mobile从url读取和显示XML文件
- jQuery Mobile Collapse上的AJAX请求
- 应用程序在呈现Jquery Mobile之前显示无样式的Html
- 如何在jQuery Mobile 1.4 Datepicker中创建事件
- UIWebview赢得't通过基本身份验证加载动态加载的资源(通过jQuery mobile)
- jQuery Mobile到其他页面的锚链接不起作用
- 如何在jQuery Mobile中设置100%宽度的输入类型日期
- JQuery Mobile破坏了我的布局:如何禁用自动打字
- 防止用户在jQuery Mobile中ajax加载页面时单击其他位置
- 根据手机上是否存在文件,在jQuery mobile中动态填充列表视图
- Image Sprites和jQuery Mobile Ajax导航的问题
- Mixing JQuery Mobile & JQuery UI