jqmobi3.0中如果要使用data-load data-unload怎么用
作者:本站编辑 发布时间:2014-10-27 来源:本站原创
点击数:
They are renamed, and there is now "before" events too. If you liked the old way, you could always write a plugin to enable it.
<code>//psuedo code
var dispatchPanelEvent:function(fnc,myPanel){
if (typeof fnc === "string" && window[fnc]) {
return window[fnc](myPanel);
}
else if(fnc.indexOf(".")!==-1){
var scope=window,items=fnc.split("."),len=items.length,i=0;
for(i;i<len-1;i++){
scope=scope[items[i]];
if(scope===undefined) return;
}
return scope[items[i]](myPanel);
}
};
$(document).on("panelload",function(e){
var hasLoad=$(e.target).attr("data-load");
return dispatchPanelEvent(hasLoad,e.target);
})
$(document).on("panelunload",function(e){
var hasLoad=$(e.target).attr("data-unload");
return dispatchPanelEvent(hasLoad,e.target);
})</code>