Subject: making EventUtil a class
Posted By: bradrice Post Date: 8/21/2006 8:15:48 AM
I'm trying to make a set of divs that will be dynamically added to a page draggable. I have been trying to decide the best way to go about it. I created a dragDiv class that I instantiate for each div. I've considered changing the EventUtil code so it becomes a class and then have the dragDiv class inherit the EventUtil code, so each div I instantiate will have it's own set of  handlers. Does it sound like I am going in the right direction? On page 292 you say because there are no properties (for the EventUtil object) and you only need one instance of this object, there's no need to define a class. It makes me think that I'm not going about my code correctly.

Reply By: nzakas Reply Date: 8/25/2006 9:42:00 PM
EventUtil is exactly what it says: a utility for working with events. You don't need to inherit from it. You can create methods to add event handlers to the DIV you want to drag directly on your dragDiv class.

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
Reply By: bradrice Reply Date: 8/29/2006 11:28:27 AM
By the way your book is awesome. I've read and re-read it so many times it is very dog eared. I rarely do that to a book. But the drag and drop is giving me fits. I just located your zDrag lib and am going through that. I think that is more what I am looking for. I was trying to adapt the simulatedDragAndDrop code to my page. I have multiple divs that I want to be draggable and have been trying to figure out how to do it without wrting methods for each one. I don't want to do getElementById inside of the functions, but somehow pass it the div I am wanting to drag.


Go to topic 48794

Return to index page 191
Return to index page 190
Return to index page 189
Return to index page 188
Return to index page 187
Return to index page 186
Return to index page 185
Return to index page 184
Return to index page 183
Return to index page 182