$.fire = function(webview, eventType, data) {
console.log("data1"+data);
console.log("$.isPlainObject(data)"+$.isPlainObject(data));
if (webview) {
if (data !== '') {
data = data || {};
if ($.isPlainObject(data)) {
console.log("SON.stringify(data) "+JSON.stringify(data));
data = JSON.stringify(data || {}).replace(/\'/g, "\u0027").replace(/\/g, "\u005c");
}
}
console.log("data2"+data);
webview.evalJS("typeof mui!=='undefined'&&mui.receive('" + eventType + "','" + data + "')");
}
};
/**
- 5+ event(5+没提供之前我自己实现)
- @param {type} eventType
- @param {type} data
-
@returns {undefined}
*/
$.receive = function(eventType, data) {
if (eventType) {
try {
if (data) {
data = JSON.parse(data);
}
} catch (e) {}
$.trigger(document, eventType, data);
}
};
var triggerPreload = function(webview) {
if (!webview.preloaded) {
$.fire(webview, 'preload');
var list = webview.children();
for (var i = 0; i < list.length; i++) {
$.fire(list[i], 'preload');
}
webview.preloaded = true;
}
};
var trigger = function(webview, eventType, timeChecked) {
console.log("timeChecked "+timeChecked);
if (timeChecked) {
if (!webview[eventType + 'ed']) {
$.fire(webview, eventType);
var list = webview.children();
console.log("list "+list);
for (var i = 0; i < list.length; i++) {
$.fire(list[i], eventType);
}
webview[eventType + 'ed'] = true;
}
} else {
$.fire(webview, eventType);
var list = webview.children();
console.log("list else "+list);
for (var i = 0; i < list.length; i++) {
$.fire(list[i], eventType);
}
}};
这上面触发mui.fire这么一直在一个自己调用的循环内啊,这么出去的,我没看明白,希望各位指点下。。谢谢。。。。追加一句,我知道什么原因了,晚上我自己眼迷糊了,看错了,,,,,
0 个回复