代码示例:
var Events = $({});
Events.on( myCustomEvent , function(){ console.log( myCustomEvent 1 ) })
Events.trigger( myCustomEvent ); // I want notify the previous binds and all binds in future
$.ajax({...}).success(function(res){
Events.on( myCustomEvent , function(){ console.log( myCustomEvent 2 ) })
});
// when ajax or other long process will be finished myCustomEvent must be fired
myCustomEvent 1 will be printed because its binded before trigger will called and myCustomEvent 2 must be trigged too
这是在jQuery的解决方案吗?