Parameters are passed when jquery references a method. jquery references parameters.

Source: Internet
Author: User

Parameters are passed when jquery references a method. jquery references parameters.

I often go to the Internet to download the js plug-ins written by Daniel. You only need to reference js and set the variables each time, but you have never understood the principle (mainly because the code of the experts is too concise -,-).

This time I learned how to pass and set multiple (many) parameters.

For example, the method is function lunbo (){};

Write when calling and setting:

Lunbo ({

Velocity: 200,

Wrapper: '# id ',

Warning: 'easing'

})

 

Then, when obtaining in the method:

Function lunbo (options ){

Var set = $. extend ({}, options );

Var _ speed = set. speed;

Var _ wrapper = set. wrapper;

Var _ sums = set. counts;

/*

Use the obtained Parameters

*/

  

}

 

In addition, when there is no way, you can set global variables for flexible use.


How does jquery bind an existing method and PASS Parameters?

Use closure + anonymous Functions
$ ("Button"). bind ("click", function (e ){
// Here, you can obtain the value of the parameter to be passed through processing e.
Para = e.tar get. foo
Abc (para)
})
--
Maybe I don't understand what you mean.
What is a button? Is it part of the component or is it written in html?
If it is a part, you can use this to point to the method call corresponding to the component.
If not, you can find the reference of the component in the anonymous function and then call the corresponding method.

In essence, jquery. bind transfers values of the parameters of the first and second functions one by one ......
---
Dizzy. js supports reflection, that is, you can call this method through the method name string. For example:
Var;
A. B = function (){/**/}
A. B () // traditional call
A ["B"] () // reflection call
Therefore, you can write an attribute (such as propFuncname) in the component to return the string of the method name, such as "abc"
Then, find the reference of the component in the anonymous function, obtain the method string through the above attributes (propFuncname), and call it through reflection.

This ensures that different methods are obtained through calling the Public Property propFuncname.

How does jquery bind an existing method and PASS Parameters?

// Here, you can obtain your parameter value para = e.tar get through processing e. fooabc (para)}) -- maybe I didn't understand what you mean. If it is a part, you can use this to point to the method call corresponding to the component. Basically, jquery. bind transfers values of the two functions one by one ...... --- Dizzy. js supports reflection, that is, you can call this method through the method name string, such as var a;. B = function () {/**/}. B () // The traditional call a [B] () // reflection call. Therefore, you can write an attribute (such as propFuncname) in the component to return the string of the method name, for example, abc ensures that different methods are obtained through calling the public attribute propFuncname.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.