Forgot to mention I moved the '-' to after the '_' in the character 
class. If you use a '-' in a character class it should be the last 
character (to avoid ambiguity because of it's special meaning inside a 
character class).

regards,

- Kev

Marko Zabcic wrote:
>
> On 29 kol, 21:55, Kevin Porter <k...@9ballpool.co.uk> wrote:
>   
>> 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.
>>     
>
> Depends on situation and amount of data. I'm using it for tree
> structure on <li> element and setting variables like:
> "_lft:5 _rgt:10 _parent_id:1 _root". I think this is very simple and
> clean solution for this situation. I'm open to any other suggestions.
>
>   
>> 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.
>>     
>
> Nice. I don't know how I thought that \w is for letters only :-)
>
>   
>> 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?
>>     
>
> It's validation limit. As it isn't meant for complex data it's not
> that big restriction. You could use '.' instead of '-' and it would be
> valid too. I've choose '-' for separator because code looks lot
> cleaner to me.
>
> Thank you for review,
> Marko
>
>
>   
>> 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 examplehttp://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 
>> Ltdhttp://webutils.co.ukhttp://billiardsearch.nethttp://9ballpool.co.uk
>>
>> AJAX Blackjack - real-time multi-player blackjack game with no flash, java 
>> or software downloads required -http://blackjack.webutils.co.uk
>>     
> >
>
>
>
>   


-- 
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