Hi, kangax wrote: > This looks interesting, but it seems like current selector abilities > can handle such case quite easily: > > // collect all "input" elements within a form with id "myForm" that > are of type "checkbox" and whose name attribute value begins with > "selectedLine" : ) > > $$('#myForm input[type=checkbox][name^=selectedLine]'); > > Enumerable methods can do this as well: > > myForm.getInputs('checkbox').findAll(function(el) { > return /selectedLine\[\d+\]\[\d+\]/.test(el.name); > })
In this job one learns all the time... ;) Thanks for suggestions. I've already created a ticket with my patch from previous post on http://prototype.lighthouseapp.com/projects/8886/tickets/18-form-getelement-accept-regexp-additionally-to-string-as-name-parameter ...but now I think that it's not necessary. The only drawback of that Enumerable.findAll method is that I need to loop again through all the checkboxes collected #myForm (witch in my case could be a few hundreds, about 50% of them are those I need). We'll see if it is fast enough. Anyway, the less personalized prototype.js the better. I already have one not-yet-in-trunk-if-ever-patch applied, this would be second change used in my production env. It's not good to have to patch each new prototype release. You could always forgot one little change and something stops working... > > As far as checking whether argument is a regexp - why not just do: > object.constructor == RegExp > yeah... why I have not thought of this? Anyway, I think not testing if the passed object is exactly a RegExp has one advantage: One could pass a simple object with test() method which could provide a custom test. But again, its easier done with findAll... Thanks for pointing me to simple solution, -- Szymon Wilkolazki --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---