I have a DIV in the following format: <div class="MyClass[Param]"> I want to parse it. Which approach is better? I can found all divs with $$(''.MyClass''), but how to find [Param] string? Or, for me, it''s better to use <div class="MyClass" id="Param"> and then found all $$(''.MyClass'').each(function(el) { el.id })? I think, the first method is better, than second one. But I don''t know how to implement it with Prototype. Thank you. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Not sure if [] is valid in a css class. Why not use two classes? <div class="MyClass Param"> $$(''.MyClass.Param'') or $$(''.MyClass.'' + someParam) -Fred On Fri, Jun 13, 2008 at 11:31 AM, AlannY <m@alanny.ru> wrote:> > I have a DIV in the following format: <div class="MyClass[Param]"> > > I want to parse it. Which approach is better? I can found all divs > with $$(''.MyClass''), but how to find [Param] string? > > Or, for me, it''s better to use <div class="MyClass" id="Param"> and > then found all $$(''.MyClass'').each(function(el) { el.id })? > > I think, the first method is better, than second one. But I don''t know > how to implement it with Prototype. > > Thank you. > > > >-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
$$(''[class="MyClass[Param]"]'') should work. Multiple classes is not a bad idea, just remember that IE ignores such css declarations (and applies only last class'' rules) - kangax On Jun 13, 12:31 pm, AlannY <m...-I/IS3f7Pe4GHXe+LvDLADg@public.gmane.org> wrote:> I have a DIV in the following format: <div class="MyClass[Param]"> > > I want to parse it. Which approach is better? I can found all divs > with $$(''.MyClass''), but how to find [Param] string? > > Or, for me, it''s better to use <div class="MyClass" id="Param"> and > then found all $$(''.MyClass'').each(function(el) { el.id })? > > I think, the first method is better, than second one. But I don''t know > how to implement it with Prototype. > > Thank you.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Param is a non constant value ;-) For example, <div class="MyClass[4342]"> I want to extract: Element (div), class name ("MyClass") and params ("4342"). So on. On Jun 13, 8:52 pm, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote:> Not sure if [] is valid in a css class. Why not use two classes? > > <div class="MyClass Param"> > > $$(''.MyClass.Param'') > > or > > $$(''.MyClass.'' + someParam) > > -Fred > > > > On Fri, Jun 13, 2008 at 11:31 AM, AlannY <m...-I/IS3f7Pe4GHXe+LvDLADg@public.gmane.org> wrote: > > > I have a DIV in the following format: <div class="MyClass[Param]"> > > > I want to parse it. Which approach is better? I can found all divs > > with $$(''.MyClass''), but how to find [Param] string? > > > Or, for me, it''s better to use <div class="MyClass" id="Param"> and > > then found all $$(''.MyClass'').each(function(el) { el.id })? > > > I think, the first method is better, than second one. But I don''t know > > how to implement it with Prototype. > > > Thank you. > > -- > Science answers questions; philosophy questions answers.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Fri, Jun 13, 2008 at 11:32 AM, AlannY <m@alanny.ru> wrote:> > Param is a non constant value ;-) > > For example, <div class="MyClass[4342]"> I want to extract: Element > (div), class name ("MyClass") and params ("4342"). So on.If the value of param is unique to an element, I''d move it to the id attribute. :Dan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
For a precise matching: $$(''div'').findAll(function(el) { return /^MyClass\[\d{1,4}\]$/.test(el.className); }) Though such approach does indeed seem weird. - kangax On Jun 13, 1:32 pm, AlannY <m...-I/IS3f7Pe4GHXe+LvDLADg@public.gmane.org> wrote:> Param is a non constant value ;-) > > For example, <div class="MyClass[4342]"> I want to extract: Element > (div), class name ("MyClass") and params ("4342"). So on. > > On Jun 13, 8:52 pm, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote: > > > Not sure if [] is valid in a css class. Why not use two classes? > > > <div class="MyClass Param"> > > > $$(''.MyClass.Param'') > > > or > > > $$(''.MyClass.'' + someParam) > > > -Fred > > > On Fri, Jun 13, 2008 at 11:31 AM, AlannY <m...-I/IS3f7Pe4GHXe+LvDLADg@public.gmane.org> wrote: > > > > I have a DIV in the following format: <div class="MyClass[Param]"> > > > > I want to parse it. Which approach is better? I can found all divs > > > with $$(''.MyClass''), but how to find [Param] string? > > > > Or, for me, it''s better to use <div class="MyClass" id="Param"> and > > > then found all $$(''.MyClass'').each(function(el) { el.id })? > > > > I think, the first method is better, than second one. But I don''t know > > > how to implement it with Prototype. > > > > Thank you. > > > -- > > Science answers questions; philosophy questions answers.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks a lot ;-) That''s what I want ;-) Thanks ;-) On Jun 14, 12:02 am, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> For a precise matching: > > $$(''div'').findAll(function(el) { > return /^MyClass\[\d{1,4}\]$/.test(el.className); > > }) > > Though such approach does indeed seem weird. > > - kangax > > On Jun 13, 1:32 pm, AlannY <m...-I/IS3f7Pe4GHXe+LvDLADg@public.gmane.org> wrote: > > > Param is a non constant value ;-) > > > For example, <div class="MyClass[4342]"> I want to extract: Element > > (div), class name ("MyClass") and params ("4342"). So on. > > > On Jun 13, 8:52 pm, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote: > > > > Not sure if [] is valid in a css class. Why not use two classes? > > > > <div class="MyClass Param"> > > > > $$(''.MyClass.Param'') > > > > or > > > > $$(''.MyClass.'' + someParam) > > > > -Fred > > > > On Fri, Jun 13, 2008 at 11:31 AM, AlannY <m...-I/IS3f7Pe4GHXe+LvDLADg@public.gmane.org> wrote: > > > > > I have a DIV in the following format: <div class="MyClass[Param]"> > > > > > I want to parse it. Which approach is better? I can found all divs > > > > with $$(''.MyClass''), but how to find [Param] string? > > > > > Or, for me, it''s better to use <div class="MyClass" id="Param"> and > > > > then found all $$(''.MyClass'').each(function(el) { el.id })? > > > > > I think, the first method is better, than second one. But I don''t know > > > > how to implement it with Prototype. > > > > > Thank you. > > > > -- > > > Science answers questions; philosophy questions answers.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---