Very interesting Marko. Passing data via class attribute probably isn't 
the 'right' thing to do, but I've chosen to do it myself on occasion. 
It's certainly a very useful function you've provided. I believe HTML5 
will allow custom attributes beginning with 'data-' for this very purpose.

I would modify your regex slightly to:

/(?:^|\s)_([\w_]+)(:([\w_-]+))*(?:)/

The changes are the '\w' instead of 'a-zA-Z0-9', and the addition of 
(?:) at the end. This isn't necessary at all, it just some dummy text to 
insert between the '*' and '/'  so the '*/' doesn't interfere with 
multi-line commenting.

Does the '-' separator for array values mean that if you have an array 
of strings, none of the values can contain a '-'? Is there a better 
character to use as a separator? I suppose you're limited if you don't 
want the code to stop pages from validating?

regards,

- Kev


Marko Zabcic wrote:
> Hi all,
>
> I've needed a way for storing data/variables on html elements and
> retrieving then through javascript. Here is the result: 
> http://pastie.org/598948
> and example http://jsbin.com/ajohi (view source code)
>
> I would appreciate you opinion on this matter and also is there a way
> to optimize/shorten regex.
>
> Thanks,
> Marko
> >
>
>
>
>   


-- 
Kevin Porter
Advanced Web Construction Ltd
http://webutils.co.uk
http://billiardsearch.net
http://9ballpool.co.uk

AJAX Blackjack - real-time multi-player blackjack game with no flash, java or 
software downloads required - http://blackjack.webutils.co.uk



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to