I need a hasEvents()
method like
var someBool = hasEvents($("#myelement"));
that returns true
if there are some bound events to any of the element's event handlers.
I need a hasEvents()
method like
var someBool = hasEvents($("#myelement"));
that returns true
if there are some bound events to any of the element's event handlers.
have you taken a look at the hasEvent()
plugin? the code is pretty small:
(function(A) {
A.fn.hasEvent = function(C) {
var B = this.data("events");
return( B && B[C] )
}
}) (jQuery)
for your specific purpose you could modify it slightly:
(function($) {
$.fn.hasEvents = function() {
return new Boolean(this.data('events') );
}
}) (jQuery);
$('#someDiv').click(function() {
alert('new event');
});
$('#someDiv').hasEvents(); // true
$('#someOtherDiv').hasEvents(); // false