Behaviours.js vs custom parameters

  • Thread starter Jean-Philippe Encausse
  • Start date
J

Jean-Philippe Encausse

Hi,

Behaviour is a really cool API mapping CSS style on JS function. This
remove ugly JavaScript functino declaration in HTML.

I would like to add a behaviour to a given html tag.
For exemple:

I have an Image <img src="path/to/image.png" class="toggle" /> and I
would like
to toggle url/class with an other on click event. So binding an onclick
event to do the toggle.

1# Where to put Event information ? -> toggleClick ? not really clean
2# Where to put target class ? -> target="newClass" ? doesn't work on
all tags.
3# Parsing custom information in StyleSheets ? complicated ...


The cleaner was would be to add dynamic attribute to an html tag using
Behaviour. Like A.attribute { element.SetAttribute("???" , "???") }
then
A.toggle { read the attributes and do the toggles } Where to find
attributes key/values ?

An other clean way would be to use custom css declaration ? But how to
do that in a crossbrowser way ?

So I don't know how to did that without writing ubgly mix of JavaScript
fuction with html or creating lots of class for one purpose.

Any Idea ?
Best Regards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,044
Latest member
RonaldNen

Latest Threads

Top