I want to override a hover event written by Drupal menu. Because I am unable to modify the code written by Drupal, I’d like to know how I can view it and then override it.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can view how the code works by inspecting the JavaScript includes in the page… I imagine with a CMS like Drupal though, with JavaScript built ontop of jQuery, trying to find exactly where this event is being added will resemble looking for a needle in a haystack.
Whilst
$('selector').off('eventName');will work in the basic case (i.e. if an event handler is attached directly to the element), it won’t work in the situation where the handler is bound to an ancestor.To easiest way to fix this is to add your own event to the element and use
stopPropagation()to stop event handlers firing that have been bound to ancestors.… a shorthand for this is to pass
falseinstead offunction:For more info see
on().