jquery mobile 如何动态的创建navbar
jquery mobile 在动态的创建navbar时候,navbar出现了两行,不是原来的那样js创建它默认生成以后的代码 有用js创建了,然后用这个进行refresh后,样式跟默认的不一样
$.widget(
"mobile.navbar",
$.mobile.navbar,
{
options : {
iconpos : "top",
grid : null,
initSelector : ":jqmData(role='navbar')"
},
_create : function() {
var t = this;
t.refresh();
},
refresh : function() {
var $navbar = this.element,
$navbtns = $navbar.find("a"),
iconpos = $navbtns.filter(":jqmData(icon)").length ? this.options.iconpos: undefined;
$navbar.addClass("ui-navbar ui-mini").attr("role",
"navigation").find("ul").jqmEnhanceable().grid(
{
grid : this.options.grid
});
$navbtns.buttonMarkup({
// corners : false,
//shadow : false,
//inline : true,
//iconpos : iconpos
icon: "",
iconpos: iconpos,
theme: null,
inline: false,
shadow: false,
corners: false,
iconshadow: false, /* TODO: Remove in 1.5. Option deprecated in 1.4. */
});
$navbar.delegate("a", "vclick", function(event) {
if (!$(event.target).hasClass("ui-disabled")) {
$navbtns.removeClass($.mobile.activeBtnClass);
$(this).addClass($.mobile.activeBtnClass);
}
});
// Buttons in the navbar with ui-state-persist class
// should regain their active state before page show
$navbar.closest(".ui-page").bind(
"pagebeforeshow",
function() {
$navbtns.filter(".ui-state-persist")
.addClass($.mobile.activeBtnClass);
});
}
});
页:
[1]