This is a jQuery plugin that is used to connect / bind a function to another function. It is more of assigning a handler for another function. Connect is used to execute a function whenever a function from another object or plugin is executed. We can connect to an event of a DOM element too using this function. In the sense same connect function can be used for both DOM elements and for the functions.
1.
$.connect(refobj,refFuncName, connObj,connFunc);
01.
function
A(){
02.
this
.fun1 =
function
(){
03.
called1 =
'calssA-fun1'
;
04.
}
05.
}
06.
var
a =
new
A();
07.
function
B(){
08.
this
.fun2 =
function
(){
09.
called2 =
'classB-fun1'
;
10.
}
11.
}
12.
var
b =
new
B();
13.
$.connect(a,
'fun1'
,b,fun2);
This is very handy to execute some function when some other function is executed from the plug-in . In order to play with it follow these steps.
- Download jquery.connect.js file.
- Include this file in your html file.
- Take help of $.connect function as illustrated to connect a function to another function.
No comments:
Post a Comment