473,394 Members | 1,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

what is the usage of jQuery.extends

56
Hi pals,
I am in a straight forward doubt. I use jQuery for a long time , but not use jQuery extends method, do any one can
explain it's purpose and need . I don't get not much from reading jQuery Manual. So if you have a Good idea reply me with a Good explanation and example....I can understand
user can create their own custom functions, pls explain ...

Thankfully
Anes P.A
Nov 30 '10 #1
3 1579
Dormilich
8,658 Expert Mod 8TB
I found the examples quite straightforward. you take in 2+ objects and get back 1 merged object. (it does not seem to have anything to do with inheritance)
Nov 30 '10 #2
amskape
56
Hi Dormilich, I got some idea about jQuery.extends , thanks for your help , pls verify my idea as I know depicted below:
$.extend(target,objects...) --->Extends the target
object with one or more specified objects.Returns the
original,unmodified object.

It's used mainly in creating plugins. For example,
in a plugin function there need some default
objects, some time we need to pass our own
preference(objects), in that time we need
to extend the deafault object with our own

eg:
Expand|Select|Wrap|Line Numbers
  1. (function($) {
  2.   $.fn.say = function(options) {
  3.     var ops = {
  4.       'word' : 'Hello'
  5.     };
  6.     return this.each(function() {
  7.       if (options) {
  8.         // here I merge the users inputted 'options' object
  9.         // with my 'ops' object.
  10.         $.extend(ops, options);
  11.       }
  12.       $(this).html(ops.word);
  13.     });
  14.   };
  15. })(jQuery);
and call this as :
Expand|Select|Wrap|Line Numbers
  1. $(document).ready(function() {
  2.   $('div').say();
  3. });
Would make all div's within a document contain the html 'Hello'.
Now, using $.extend() we can override the word hello with 'goodbye'.
Expand|Select|Wrap|Line Numbers
  1. $(document).ready(function() {
  2.   $('div').say({word: 'Goodbye'});
  3. });
Am I right Dormilich, If my understanding has any
problem advise me

Regards
Anes P.A
Dec 1 '10 #3
Dormilich
8,658 Expert Mod 8TB
I’m not much of a jQuery user …
Dec 1 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

26
by: Steven Bethard | last post by:
I thought it might be useful to put the recent lambda threads into perspective a bit. I was wondering what lambda gets used for in "real" code, so I grepped my Python Lib directory. Here are some...
5
by: ziobudda | last post by:
Hi, I want ask you if, for a web portal/application, is better prototype or Jquery? I don't want to innesc some type of flame, but after the announce that drupal use JQuery and that the new...
2
by: maheswaran | last post by:
Hi what is Jquery (Knew it'a javascript lib), How can i use with php?... Could you give a sample?...
83
by: liketofindoutwhy | last post by:
I am learning more and more Prototype and Script.aculo.us and got the Bungee book... and wonder if I should get some books on jQuery (jQuery in Action, and Learning jQuery) and start learning about...
14
by: gimme_this_gimme_that | last post by:
What is going on here with the dollar signs and parenthesis? $(document).ready(function(){ $("li").behavior("click",function(){ $(this).load(menu.html"); }); }); And when do you use click...
20
by: Aaron Gray | last post by:
There does not seem too be anyway to test if two jQuery references are the same element. Given :- ... <div id="1"></div .... Then :- alert( $("#1") == $("#1"))
26
by: RobG | last post by:
Do some of the regulars here need to re-think their (sometimes strident) opposition to libraries? Both Microsoft and Nokia have announced support for jQuery. It seems to have gained quite a bit...
34
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - What online resources are available? ----------------------------------------------------------------------- *...
53
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.