[mochikit] Re: Not sure how to properly pass parameters to connect().

2006-10-18 Thread troels knak-nielsen
Hey, thanks for correcting me. I remember reading about the allegedly optimization pitfall some years ago, and somehow just stored it in my memory as a piece of truth. I never even bothered to think it through, but your explanation makes perfectly sense. On 10/17/06, Bob Ippolito [EMAIL

[mochikit] Re: Not sure how to properly pass parameters to connect().

2006-10-17 Thread troels knak-nielsen
Apart from the obvious, that Bob had event.stop(); in his example (Which you could add if you need it, but most likely you don't), there is one peculiar detail. Some javascript interpreters optimize closures like this, so they can be reused if called multiple times. This would happen if you

[mochikit] Re: Not sure how to properly pass parameters to connect().

2006-10-17 Thread Bob Ippolito
Both you and the blog entry are confused here. That's not an optimization, that's how scope works in JavaScript. All implementations MUST do that. The quote he referenced is completely irrelevant to the behavior that his code has. Closures don't snapshot the state of the program.. they just

[mochikit] Re: Not sure how to properly pass parameters to connect().

2006-10-16 Thread Chris
Bob Ippolito wrote: Like most languages in common use, function calls always execute exactly where they are in the code. What you're doing is actually this: var result = change_html('target1', 'new html'); connct('target1', 'onclick', result); That clearly is not what you want. haha yes

[mochikit] Re: Not sure how to properly pass parameters to connect().

2006-10-14 Thread troels knak-nielsen
Or simply: connect('target1', 'onclick', function() { change_html('target1', 'new html'); }); On 10/14/06, Bob Ippolito [EMAIL PROTECTED] wrote: On 10/13/06, Chris [EMAIL PROTECTED] wrote: Hello, I'm just trying to do a really simple thing by setting an event on an element with

[mochikit] Re: Not sure how to properly pass parameters to connect().

2006-10-13 Thread Bob Ippolito
On 10/13/06, Chris [EMAIL PROTECTED] wrote: Hello, I'm just trying to do a really simple thing by setting an event on an element with connect() and then changing that element's html with innerHTML. But I'm not sure how to properly pass parameters through connect() to my function. I can see