JavaScript更合理/更快:使用callbacks()
或对events
作出反应?
JavaScript:回调
doSomething(function(){
//one or more callbacks (onSuccess, onError, etc)
});
JavaScript:活动
function initSomething(){
//do something
$(document).trigger('reactOnEvent');
}
$(document).on('reactOnEvent', function(){
//callback via event
});
initSomething();