A LIST Apart: For People Who Make Websites

No. 218

Discuss: Behavioral Separation

Pages

 1 2 3 >  Last »

1 İt's usefull article... :)

Hi, it’s usefull article, i will say thanks… :)

posted at 07:43 am on June 20, 2006 by Umut Akyol

2 Want more?

If you liked the article and want to read more, definitely check out Jeremy’s book, DOM Scripting. He didn’t plug the book, and most people have heard of the book, but this article is a great example of what you can find in the book.
-Chasen

posted at 08:05 am on June 20, 2006 by Chasen Le Hara

3 This is really nice!

I hate adding JS and it messing up my page and making it look horrid.

It would be great to use this method and then link to a page saying how JavaScript is required to use a function for example.

Have ordered the book :)

posted at 09:25 am on June 20, 2006 by Rob McMichael

4 Behaviour : Using CSS selectors to apply Javascrip

The Behaviour library greatly simplifies this type of separation. Standard CSS selectors are used to apply javascript behavior. The image gallery separation example of the article condenses to this (not tested):

var myrules =
{ ‘#imagegallery a’ : function(element) { element.onclick = function(element){ return showPic(element); } }
};
Behaviour.register(myrules);

posted at 10:52 am on June 20, 2006 by Ted S

5 Will be looking for more DOM info

Wow, this article makes a lot of sense, and gives me a new way of looking at things for web pages and web art. I am a little confused about the object module stuff, but you have sparked my curiousity enough with a more effecient way of doing things that I must learn more.

posted at 11:06 am on June 20, 2006 by Kimberly Katrell

6 Behaviour

Ted, you’re quite right about the Behaviour library. I especially like the motivation behind it. From the website:

“It’s great to see public uptake of these technologies – but it worries me to see the influx of script tags and onclick attributes into webpages.”

It’s also nice and lightweight.

The usual caveats apply: make sure you understand the code, and be aware of any cross-browser issues. But yes, Behaviour is well worth checking out.

posted at 11:10 am on June 20, 2006 by Jeremy Keith

7 Slight caveat...

It’s worth remembering that onLoad only fires when all elements of the page have loaded; on pages where there are many graphics, etc., there can be a substantial lag between when controls are loaded and when they become accessible.

Dean Edwards has a cross-browser solution which should give this type of javascript code management an extra level of useability.

posted at 11:40 am on June 20, 2006 by Scott Matthewman

8 Great article

Nice to see this technique explained in an ALA article. I have been using Behaviour for a little while and love it. It is nice to see an explanation of how to code it “ by hand”, so to speak.

posted at 11:43 am on June 20, 2006 by Martin Westin

9 About CSS and Events...

Thank you for this good article. It is well written and explains in a few words the reasons for switching to this “new javascript”.
I enjoyed reading it as it is a topic I’m very interested in. For those interested, I wrote two Javascript “includes” (object in fact): an events manager, and a CSS styles manager; those can be found here:
http://yves.gablin.club.fr/gablin.php?page=pc_javascript

Yves.

posted at 12:47 pm on June 20, 2006 by Yves Gablin

10 It's not always necessary

You don’t always have to do your separation at the client level if it’s more work than it’s worth. A shining example is the Ruby on Rails framework which produces seemingly nasty inline JS hooks. It’s okay, though, because the code RoR generates for your is irrelevant in a management aspect, just as long as it works. This is because the generators already provide the separation for you. Setting up the generators to write the JS to a main [removed] tag just for the asthetics would be pointless.

posted at 12:56 pm on June 20, 2006 by Rad Smith

Pages

 1 2 3 >  Last »

Discussion Closed

New comments are not being accepted, but you are welcome to explore what people said before we closed the door.

Got something to say?

Discuss this article. We reserve the right to delete flames, trolls, and wood nymphs.

Create a new account or sign in below if you’d like to leave a comment.

Remember me

Forgot your password?

Subscribe to this article's comments: RSS (what’s this?)