JQuery Developer Question:

Explain using $.connect function in jQuery?

Tweet Share WhatsApp

Answer:

The syntax of connect function is
$.connect(sourceObj/*object*/, sourceFunc/*string*/, callObj/*object*/, callFunc/*string or Func*/)

sourceObj(optional) is the object of the source function to which we want to connect
sourceFunc is the function name to which we want to connect
callObj(optional) is the object which we want to use for the handler function
callFunc is the function that we want to execute when sourceFunc is executed.

Here sourceObj, callObj are optional for the global functions.
suppose if your sourceFunc is global function then no need to pass the sourceObj or you can use null or self
suppose if your callObj is global function then no need to pass the callObj or you can use null or self

ex:
// fun1, fun2 are global functions
1. $.connect('fun1',fun2)
2. $.connect(null,'fun1',fun2)
3. $.connect(self,'fun1',fun2)
4. $.connect('fun1',null,fun2)
5. $.connect('fun1',self,fun2)
6. $.connect(self,'fun1',null,fun2)

Download JQuery Developer PDF Read All 51 JQuery Developer Questions
Previous QuestionNext Question
Explain use of jQuery.connect?Do you have plans for a new jQuery plug-in or something else we should look out for? Where to from here for the imgPreview plugin?