Is it possible to use jquery .on()
method instead of .delegate()
when there is no event to be listened to?
According to the .on()
documentation:
.on( events [, selector] [, data] , handler(eventObject) )
The events
argument is not optional.
The use of .on()
/.delegate()
is for elements that are added dynamically.
You can use custom events:(it IS still an event, but YOUR event )
markup:
<div id='mePlease'>
<div id='noWay'>Hi</div>
</div>
$('#mePlease').on('wacky','#noWay',function(){
alert('wackyEnough');
});
$('#noWay').trigger('wacky');
but really, this could be done with a simple function call.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With