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]

JavaScript outside the browser

http://javascript.weblogsinc.com/2006/08/06/javascript-outside-of-the-browser/ After reading the above article, questions comes in mind, why JavaScript outside the browser? So let’s go through on some points which strongly recommend the future of “the world’s most misunderstood programming language”. 1. JavaScript will be treated as a significant programming language in the upcoming days 2. JavaScript speed and performance, of course [...]

Show Love to the Object Literal | Core JavaScript 1.5 Guide:Literals

Defining an object is via literal notation. Supported in JavaScript1.2 and above, it’s a more robust form of creating an object on the fly. Neat and clean approach to write reusable, readable and maintainable JavaScript code. Show Love to the Object Literal: http://ajaxian.com/archives/show-love-to-the-object-literal Object literals beauty lies in Namespaces, which reduces the number of global [...]

Working draft of HTML5

Are you ready for next gen HTML5 with DOM interface? I am amazed even removing iframe from XHTML 1.0 “strict mode” they have included it once again in HTML5 with better control. For the lovers of Web Forms 2.0: Design a form that uses autocompletion (intellisense for me) like we do using AJAX (not up [...]

What are Web Standards?

The term web standards can mean different things to different people. For some, it is ‘table-free sites’, for others it is ‘using valid code’. However, web standards are much broader than that. A site built to web standards should adhere to standards (HTML, XHTML, XML, CSS, XSLT, DOM, MathML, SVG etc.) and pursue best practices [...]

  • 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