Reputation: 1036
So I was given code that looks like
this.$dropdownButton.off('click.fpmenu').on('click.fpmenu', function (evt) {});
where
this.$dropdownButton
Is a valid button element.
However, at the same place if I search for .fpmenu ($('.fpmenu')
), I don't get anything.
Is the on/off events that I am trying to attach to $dropdownButton
suppose to be a delegate of the click function of fpmenu? If it can't find fpmenu, would it cause the event not to be attached?
Upvotes: 2
Views: 2032
Reputation: 191976
The fpmenu
is the namespace of the event handler. This enables jQuery to remove specific event handlers, without changing others.
See Event names and namespaces in jQuery's .on()
documentation.
Example - click button and see which event handler is called
var button = $('button');
button.on('click.fpmenu', function () { console.log('fpmenu'); }); // add fpmenu named event
button.on('click.somethingElse', function () { console.log('somethingElse'); }); // add somethingElse named event
button.off('click.fpmenu'); // remove fpmenu named event
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button>click me</button>
Upvotes: 2