代码示例:
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' 将被打印,因为它在触发器之前绑定将被调用并且 'myCustomEvent 2' 也必须被触发
jQuery中有什么解决方案吗?