File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Extending jQuery? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Extending jQuery?" Watch "Extending jQuery?" New topic
Author

Extending jQuery?

suhaib mustafa
Greenhorn

Joined: Apr 01, 2012
Posts: 10
Hi,
What does extending jQuery mean?? I have used jQuery(even jQuery plugins) but never thought in this front. Can anyone please explain what extending jQuery is and what are its advantages?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Extending jQuery means the creation of plugins and add-ons. If you have used plugins, then you already know what the advantages are -- it allows jQuery core to concentrate on the things that most people need, and to allow the use of plugins for everything else.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
suhaib mustafa
Greenhorn

Joined: Apr 01, 2012
Posts: 10
Whats is different in using jQuery in our applications and creating plugin/addons using same? can a plugin itself be extendable? i.e; one more plugin can be created by extending this plugin-if at all it is possible . Can you brief me on what topics are covered in the book?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Sure, plugins can be built to be further extended. The jQuery UI framework is a good example -- in fact, has a complete Part in the book devoted to it.

The Table of Contents for the book is available here.
B. Katz
Ranch Hand

Joined: Aug 28, 2009
Posts: 51

Great and thank you, Bear.

Now, a thought comes to mind in regards to this; When extending another plugin, I should think that versioning would become even more critical to making sure that things run exactly as expected, right? At that point you would have to keep track of both the version of jQuery as well as the version of the plugin you are extending.


"I do not feel obliged to believe that the same God who has endowed us with sense, reason, and intellect has intended us to forgo their use."
-- Galileo Galilei
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Good question -- I know that most plugins declare what version that they work with. I'm not sure if any do such checking in code. It's easy to see that that's something that'd be hard to future-proof.

I'd be interested to hear Keith's take on this!
Keith Wood
Author
Ranch Hand

Joined: Aug 28, 2012
Posts: 38

By "extending jQuery" I mean the writing of a section of code in the form of a plugin that can easily be reused on many pages. As Bear said, this lets jQuery concentrate on the functionality used by most people without bloating the library with rarely used abilities. The plugins integrate with fully into the normal jQuery processing and can take advantage of its other capabilities. The benefits of creating a plugin include consistency of appearance and behaviour across your Web site and reduced maintenance as there is only a single copy of the code to test and update.

You can extend existing plugins and override or add functionality to them - some more easily than others depending of how they are written. jQuery UI is designed to be extensible - most of its plugins extend its Widget module, or those that interact with mouse drags extend the Mouse module. You can enhance one of the jQuery UI widgets by using it as the basis for your new plugin.

Some plugins add their own internal extension points. For example, the Validation plugin lets you add new validation rules and class rules. My Calculator plugin lets you add new buttons/functions to it. However, these are isolated examples and each plugin does this its own way.

Versioning of plugins is always a problem - even just with jQuery itself. At least with jQuery and jQuery UI there is a built-in version number that you can check - $.fn.jquery and $.ui.version respectively. Most plugins don't provide this facility. Maybe this should be added to the list of best practices.


Author of the upcoming "Extending jQuery" book from Manning.
 
Don't get me started about those stupid light bulbs.
 
subject: Extending jQuery?
 
Similar Threads
Bumper Sticker item requests
WA #1.....word association
jQuery vs MicroJS and the like
Extending jQuery; version number
Extending JQuery