Home Register Members List Search Today's Posts Mark Forums Read

Go Back   TechFuels Forum > Technology Jargons - What is ....? > Software Jargons > Operating System

Reply
 
LinkBack Thread Tools
uncosto46
Senior Member
 

uncosto46 is offline  
Old 08-02-2008, 01:17 PM
  #1 (permalink)
Event chaining in JavaScript Objects.

It's quite often the case that you'll need to chain together some events arbitrarily to produce an action/reaction effect. The dojo. connect function provides a seamless interface for arbitrarily connecting events and JavaScript Objects. For example, you already know that you could hook up a handler when a user mouses over a specific node by using dojo.query and assigning a function via dojo.NodeList's onmouseover method like so:

dojo.query("#foo") //find the node with id=foo .onmouseover(function(evt) ( /* ... */ I);
An alternative implementation via dojo. connect is the following statement, which assembles the connection and returns a handle that can be disconnected later manually if the situation calls for the relationship to be torn down. For example, it's generally a good idea to tear down
the handle explicitly before destroying nodes that are involved in the connection:
va! h = dojo.connect(dojo.byld("foo"), "onmouseover", function (evt) I
/' Later */
dojo.disconnect(h); //tidy up things ...
Although the net effect is the same for the two implementations presented, dojo. connect seamlessly allows you to provide Objects as the context. For example,

Name:  Event chaining in JavaScript Objects..jpg
Views: 167
Size:  17.9 KB

How To Developers I the following variation illustrates how to fire off an event handler whenever a particular function is invoked:
var obj = ( / / a big hash of functions ...
foo function() /' */ I,
bar: function() ( /* ... */ )
/ / set the handler to fire whenever obj. foo () is run dojo.connect(obj, "foo", function()
If you want to use a particular scope with the custom handler, you can wedge it in as a third parameter. The parameters are all normalised internally. Here's how it would work:
var obj 1 = ( / / a big hash of functions .. foo function () /* * / I,
bar: function() { /* ... */ I
var obj2 = ( / / a big hash of functions. baz : function() { /* ... */ }
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Align objects on a slide eirn.wonal Web. 2.0 0 06-26-2008 12:47 PM
Event subscriptions owinsh.jafonh Windows Vista 0 06-25-2008 02:06 PM
Creating And Grouping Objects in phun hassik54 Everything Else 0 05-21-2008 12:52 PM
Showing the event calendar on the site techpro Applications 0 04-08-2008 11:46 AM
Javascript techno23 Programming 0 03-26-2008 11:56 AM


All times are GMT +1. The time now is 02:55 PM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.0
Copyright Techfuels -->
SEO by SubmitEdge


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151