You need to trigger an event on a certain element (or many). This element belongs to one or more plugins so it may have event handlers bound to this event.
The problem is that this event is a common one, like click or mousedown. Simply triggering the event could run other event handlers that you didn’t expect.
On the same principle as the previous recipe, namespaces can be used for triggering as well. When binding, you need to make sure you add a unique namespace to each set of handlers.
This can also be used for the opposite situation; if you need to trigger any event except those with a namespace, you can use the ! operator. An example of this will be shown in the discussion.
How to trigger handlers with a certain namespace?
Now, say you want to programmatically trigger the click event bound by the plugin myPlugin. You could simply trigger the click event, but that would be a bad approach,because any other handler bound to the same event would get fired as well.
This is how to do this properly:
How to trigger handlers that do not have a namespace?
On the contrary, maybe you need to trigger a click (or any other event), but the target element belongs to one or more plugins. Triggering an event could run undesired event handlers, and that would cause problems that will be pretty hard to debug.
So, assuming all the plugins did use a namespace, this is how to trigger a click safely:
J Query Related Interview Questions
|HTML 4 Interview Questions||HTML Interview Questions|
|HTML 5 Interview Questions||Zend Interview Questions|
|JqueryUI Interview Questions||Dynamic HTML Interview Questions|
|XQuery Interview Questions||jQuery Mobile Interview Questions|
J Query Related Practice Tests
|HTML 4 Practice Tests||HTML Practice Tests|
|HTML 5 Practice Tests||Zend Practice Tests|
|PHP and Jquery Practice Tests||J Query Practice Tests|
|CodeIgniter Practice Tests||Dynamic HTML Practice Tests|
J Query Tutorial
Selecting Elements With Jquery
Beyond The Basics
Faster, Simpler, More Fun
Html Form Enhancements From Scratch
Html Form Enhancements With Plugins
Interface Components From Scratch
User Interfaces With Jquery Ui
Jquery Ui Theming
Jquery, Ajax, Data Formats: Html, Xml, Json, Jsonp
Using Jquery In Large Projects
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.