Creating Special Event in Zepto
by goje87
JavaScript
(function($) {
$.event.special = [];
var _clone = function(fn) {
return eval(fn);
};
// _on(event, selector, callback);
$.fn._on = _clone($.fn.on);
$.fn.on = function(event, selector, callback) {
if(event == 'myEvent') {
alert('caught it');
//return this;
}
return this._on(event, selector, callback);
};
})(Zepto);
console.log('start');
$(document.body).on('myEvent', function() {
console.log('body is ready');
});
$(document.body).trigger('myEvent');