Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with unobtrusive JavaScript

 
Karim Kiswarday
Ranch Hand
Posts: 50
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello rancheros,
I would like to ask you about a problem of unobtrusive javascript.

I know it's very good to separate behavior from structure but if I put events code in an external file for example, when in the future I will look again the HTML code, I will have problems to remember where my functions are invocate.

For example, if I have the below HTML code:

and in an external javascript file I have:

it's very difficult to know that pic1 has a javascript function.

How do you resolve this type of problem?

Thanks
KK
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't. If you don't want to keep the behavior separate from the structure, you don't want to use Unobtrusive JavaScript. It's kind of like asking how you can eat beef and still be a vegetarian.

The same thing applies to CSS. You can't see what styles are applied to the elements by just looking at the structure. You need to look at the CSS. In Unobtrusive JavaScript, you need to look at the script to know what behavior is applied.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic