[Prototype-core] Re: bracket notation

2007-06-22 Thread Andrew Dupont
On Jun 21, 2:35 pm, sed [EMAIL PROTECTED] wrote: I'm not sure why this worked before, it must be related to the html/ script being generated into the div from the ajax.updater rather than just being on the page. Nope. It's sillier than that. Let's say you've got an element with an ID of foo

[Prototype-core] Re: bracket notation

2007-06-22 Thread Miha Zimin
Hi guys. I'm new in prototypejs and script.aculo. But, lets consider Andrew Dupont's example again: var f = new String(foo); alert($(f)) //- foo alert(document.getElementById('foo')) //- [object HTMLElement] It has cause: When String( ) is used as a constructor with the new operator, it

[Prototype-core] Re: bracket notation

2007-06-22 Thread Mislav Marohnić
On 6/22/07, Tobie Langel [EMAIL PROTECTED] wrote: The String function/constructor is maybe useful for other things [...] Like what exactly !? Like when casting something to string when toString is not sufficient. I don't know when that may be. I was just stating this: although this may be

[Prototype-core] Re: bracket notation

2007-06-22 Thread jdalton
I don't see the harm in adding the second condition element instanceof String you could use : if(element element.constructor == String) This works for both foo and new String(foo); I find that it is faster than using typeOf. I have made very JavaScript heavy applications and noticed that

[Prototype-core] Re: bracket notation

2007-06-22 Thread Mislav Marohnić
On 6/22/07, Tobie Langel [EMAIL PROTECTED] wrote: I'm actually getting faster results in Firefox for typeof in that particular case. Me too. Try it for yourself: http://gfx.neohub.com/benchmark/creator.html --~--~-~--~~~---~--~~ You received this message

[Prototype-core] Re: bracket notation

2007-06-22 Thread jdalton
If you run it more than once you get different results. Reguardless of this benchmark (I got it to show .constructor was faster consistently more times, IE) Its a method of detecting a string that will fix the issue. --~--~-~--~~~---~--~~ You received this

[Prototype-core] Re: bracket notation

2007-06-22 Thread jdalton
And using : http://gfx.neohub.com/benchmark/creator.html Firefox: slower by alot using constructor IE : faster by alot using constructor return ('hi'.constructor == String); vs return (typeof 'hi' == 'string'); IE: faster by alot using constructor Firefox : mixed (sometimes slower sometimes

[Prototype-core] Re: bracket notation

2007-06-21 Thread Mislav Marohnić
On 6/21/07, sed [EMAIL PROTECTED] wrote: I've posted this question to ruby on rails, but figured people here would be more likely to know the answer. Using bracket notation in javascript seems to stop workiing when prototype is included. I'm not using the notation, but if Prototype breaks

[Prototype-core] Re: bracket notation

2007-06-21 Thread Ryan Johnson
This is very very unlikely. I use bracket notation with and without prototype on many scripts that work cross browser. Check which other libraries you are including, and make sure it is not a problem or missing attribute of the object you are working with. On Jun 21, 8:41 am, sed [EMAIL

[Prototype-core] Re: bracket notation

2007-06-21 Thread sed
Interesting problem here and I don't think it's a prototype bug, but I corrected the issue. Here is what was happening if anyone's interested Here is a short explanation: Ajax Call generates some html into a div with this function inside: GetNextField = function() {return('thenextfield');}; In