On Fri, May 15, 2009 at 12:05 AM, kangax wrote:
>
> On May 14, 8:24 pm, Gabriel Gilini wrote:
> > var classNamesRegex = new RegExp('\\b(' + classesArr.join('|') + ')\\b');
> //
> > Generates /\b(foo|bar|foob)\b/
>
> Please don't use boundaries to separate class values. I wonder who
> came up wit
On May 14, 8:24 pm, Gabriel Gilini wrote:
> On Wed, May 13, 2009 at 3:34 PM, louis w wrote:
>
> > I have an array containing a number of strings. I would like to
> > continue exucuting my script only if an item has ANY/ALL of the
> > strings assigned as a class name.
>
> > $A(['foo', 'bar', 'foo
On Wed, May 13, 2009 at 3:34 PM, louis w wrote:
>
> I have an array containing a number of strings. I would like to
> continue exucuting my script only if an item has ANY/ALL of the
> strings assigned as a class name.
>
> $A(['foo', 'bar', 'foob']);
>
> Is there an elegant want to do this without
@Matt:
> I believe using the non-methodized version of this method would be
> better
>
> Element.hasClassName.curry(element);
Ah, yes, well spotted. Probably not a huge difference, but certainly
a positive one. E.g.:
if (['foo', 'bar', 'foob'].any(Element.hasClassName.curry(element))) {
//
I think you misinterpreted what I was saying. Simply "swapping" bind
for curry will certainly generate errors.
I don't really feel like explaining it and its of potentially trivial
performance results but, savor some of this syntax...
var ele = $("container");
var arr = $w("foo
Thanks guys. I am going to compare the difference in processing time
of TJ's suggestions. It will be called often (from a Form Observer).
For now I am using this one:
if
(_validate_field_classes.any(element.hasClassName.bind
(element))) {
Wasn't aware of the any function
> var test = ['foo', 'bar', 'foob'];
> if (test.any(element.hasClassName.bind(element))) {
I believe using the non-methodized version of this method would be
better
Element.hasClassName.curry(element);
--
http://positionabsolute.net
On May 14, 12:30 pm, "T.J. Crowder" wrote:
> Hi,
Hi,
I can think of two approaches off-hand:
1. Use Enumerable#include on the array of classes you want to test
against, using Element#hasClassName as the iterator function (bound to
the instance), e.g.:
var test = ['foo', 'bar', 'foob'];
if (test.any(element.hasClassName.bind(element)))
I'm not sure if include would work if an item has more then one class.
Given these classes: $A(['foo', 'bar', 'foob']);
Would match:
hi
hi
Would not match
Hi
Hi
I guess i am going to have to iterate the classes to check, was hoping
there was a more elegant solution.
On May 13, 11:09 pm, "ra
Hi,
i think you can you can use which will return either true or false
depending upon.
I think this one works.
Thanks
On Thu, May 14, 2009 at 12:19 AM, louis w wrote:
>
> I have an array containing a number of strings. I would like to
> continue exucuting my script only if an item has ANY/AL
10 matches
Mail list logo