Unlike some of the other Scripty Actions, I didn’t add any “marker” classnames to the elements, so it’s not currently possible to use CSS directly to do this. If you have a specific page structure laid out, and have applied the Action to the element, could you post that somewhere and send a link? I may be able to come up with a “side-car” approach to tack this on using the Protaculous Action.
Dave, since you’ve already got prototype.js in your page, then the cngClass method could be written like this (choose prototype-packed from the Protaculous Library picker):
The first block of code adds a ‘cngClass’ method to all elements on the page, allowing them to toggle the ‘pointer’ classname, so that only one of them per parent container will have it at a time. This method is automatically extended onto every element in the page, with no extra effort or code needed. Next, the one-liner hooks all of the H3 tags in the ‘yourBox’ DIV to have them respond to the click event by running the cngClass method. And the tail-call function at the end applies the method to the first H3 in the box, so that it will get the “open” appearance when the page loads.
My problem with your method Walter is that mine (not really mine at all - borrowed) changes the class on the accordion headers whereas yours (as I read it) removes a class.
So I am struggling to get yours to change it rather than remove it.
Mine does two things. First, it finds any peers of the current item that already have the pointer class applied to them, and removes that (this is so that only one element has the pointer class at any one time). Next, it applies the pointer class to the current item.
Note also that I made a mistake with the one-liner, it’s not quite as simple as I had it, because we are hooking the click event, not the element itself.
My problem with your method Walter is that mine (not really mine at all - borrowed) changes the class on the accordion headers whereas yours (as I read it) removes a class.
So I am struggling to get yours to change it rather than remove it.
On Apr 29, 2012, at 9:33 PM, Walter Lee Davis wrote:
Mine does two things. First, it finds any peers of the current item that already have the pointer class applied to them, and removes that (this is so that only one element has the pointer class at any one time). Next, it applies the pointer class to the current item.
Note also that I made a mistake with the one-liner, it’s not quite as simple as I had it, because we are hooking the click event, not the element itself.
My problem with your method Walter is that mine (not really mine at all - borrowed) changes the class on the accordion headers whereas yours (as I read it) removes a class.
So I am struggling to get yours to change it rather than remove it.
Hi Dave and Walter
thanks for your reply and many thanks for your example Dave. I try to apply it in my document.
Also curious to the updated page with Walters code.