Well, you probably shouldn't be using .each() for that. Use something
like .find() instead:
var found = pattern.find(function(pat){ return obj.value.include(pat); });
if (found) {
obj.next().insert('found: ' + pat + '|');
__selectString(obj, pat);
}
# Tobias
2008/10/4 kstubs <[EMAIL PROTECTED]>:
>
> I am iterating through an array, but it fails to break on the return
> statement. What is working, and is suppose to be deprecated is the
> throw $break. So, some example code:
>
> var pattern = obj.readAttribute('pattern').split('/');
>
> pattern.each(function(pat)
> {
> // make selection based on pattern
> if(obj.value.include(pat) )
> patternfound = true;
>
> if(patternfound)
> {
> obj.next().insert('found: ' + pat + '|');
> __selectString(obj, pat);
> return;
> }
> });
>
>
> So the obj.next, that is a span tag, and the output looks like:
> found: DD|found: YYYY|
>
> Which indicates that it finds all possible patterns, but should break
> on the first find of DD. When I replace the "return;" statement above
> with: throw $break, the code behaves as expected and I get the
> following output:
>
> found: DD|
>
> So what give? Any ideas on this?
>
> Karl..
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---