09.02.2015 Views

DOM Traversal Methods - MarkMail

DOM Traversal Methods - MarkMail

DOM Traversal Methods - MarkMail

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Plug-In API<br />

<br />

<br />

Example<br />

<br />

After that, we're ready to use any of the methods made public by the plug-in. For<br />

example, using the Form plug-in, we can add a single line inside our custom file's<br />

$(document).ready method to submit a form via AJAX:<br />

$(document).ready(function() {<br />

$('#myForm').ajaxForm();<br />

});<br />

Each plug-in is independently documented. In the subsequent chapters, we will<br />

examine a couple of the more prominent plug-ins in detail, describing each of their<br />

methods. To find out more about other plug-ins, we can explore the documentation<br />

linked from the jQuery plug-in repository, or read the explanatory comments found<br />

in the source code itself.<br />

If we can't find the answers to all of our questions in the plug-in repository, the<br />

author's website, or the plug-in's comments, we can always turn to the jQuery<br />

discussion list. Many of the plug-in authors are frequent contributors to the<br />

list and are always willing to help with any problems that new users might face.<br />

Instructions for subscribing to the discussion list can be found at<br />

http://docs.jquery.com/Discussion.<br />

Developing a Plug-in<br />

As we discussed above, plug-in development is a useful technique whenever we are<br />

going to perform a task more than once. Here we will itemize the components that<br />

can populate a plug-in file of our own design. Our plug-ins can use any combination<br />

of the following four types of jQuery enhancements: object methods, global functions,<br />

selector expressions, and easing styles.<br />

Object Method<br />

Adds a new method to all jQuery objects created with the $() factory function.<br />

jQuery.fn.methodName = methodDefinition;<br />

[ 184 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!