Build your first jQuery plugin

First and far most, we should say thanks to John Resig and his team to make our life so easier then before by making jQuery, most demanding and powerful JavaScript framework and it’s expanding phenomenally that gives the proof of dominancy of jQuery framework.

So why do I need to extend jQuery?

Here we go; no library is full filling all the requirements so does jQuery, so there should be some mechanism to add sets of useful methods called as plugins for your specific requirement, which we can say in the basic terminology calling your external methods into your structure but it doesn’t give you the power of leverage existing code base.

Let’s say, by creating a new jQuery commands, we automatically inherit the use of powerful selector mechanism and can use all the jQuery methods and indeed it’s a good practice to make reusable code.

There is a pretty good documentation and guidelines available on jQuery Plugins/Authoring page.

Let’s start making our first jQuery plugin; we call our plugin as “disable”, we make our plugin to disable the form elements and then we will extend our default options using $.extend utility method to enable the required once.

We will follow the guidelines as provided on jQuery.com so we will save our plugin as jquery.disable.js

[sourcecode language='js']
// plugin definition
$.fn.disable = function() {
// plugin implementation code goes here.
};
[/sourcecode]

Who is better TypePad or WordPress?

After investigating for 15 days, need to get the better blogging platform for our client who wins lastly? Guess guys! Professionally TypePad, due to the client demand because they are not willing to spend money creating new infrastructure like setting up Apache/MySQL for WordPress on their environment. TypePad doesn’t need all that, they host on [...]

Google Chrome: the Google Browser

Google Chrome: the Google Browser Google announced today that they will release their own browser tomorrow, code named Google Chrome. Beta version will be launched tomorrow morning only, initially available only for Windows. Google Chrome is open source and based on WebKit, which is the same engine used by Safari and Adobe AIR. This is [...]

  • Metadata
  • View Mohammed Arif's profile on LinkedIn
  • Follow arif_iq on Twitter
  • Technorati Profile
  • Add to Technorati Favorites
  • Calendar

    • September 2010
      M T W T F S S
      « Jun    
       12345
      6789101112
      13141516171819
      20212223242526
      27282930  
  • Search