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]
November 7th, 2008
Categories: JavaScript, Technology, Web 2.0 . Author: Mohammed Arif . Comments: 8 Comments
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 [...]
July 21st, 2008
Categories: JavaScript, Web 2.0, Web Browsers . Author: Mohammed Arif . Comments: No Comments
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 [...]
June 10th, 2008
Categories: JavaScript . Author: Mohammed Arif . Comments: 1 Comment
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 [...]
June 26th, 2007
Categories: (X)HTML, JavaScript . Author: Mohammed Arif . Comments: No Comments
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 [...]
June 25th, 2007
Categories: (X)HTML, CSS, JavaScript, Web 2.0, Web Standards . Author: Mohammed Arif . Comments: 1 Comment