A list of paragraphs (<p>) is given. As soon as the user clicks on paragraph A the class of paragraph A changes to ‘activated’. Now the user selects paragraph B and all the paragraphs between A and B change their class to ‘activated’.
By clicking on B again, only A remains with the class ‘active’.
By clicking on A the class ‘active’ gets removed on all paragraphs between A and B (including A and B).
It shouldn’t be possible to ‘deactivate’ any paragraph between A and B. The selection between A and B should always be a uninterrupted list of selected paragraphs.
Can anyone give me a hint on how to realize this with Prototype/Scriptaculous? The application is implemented in Rails, so any hint in RJS would even be more appreciated!
OK, in the meantime and with the help of a coworker I came up with an own answer to this problem:
class_flipper_init()is called everytime the page (or in my case a certain partial) is loaded.Please don’t hesitate to submit a solution written in ‘pure’ RJS or something more elegant. 🙂