Re: [jQuery] Best practices for reattaching behaviours to dynamically loaded content?

2007-03-05 Thread Nicolas Hoizey
I keep all my behaviours in separate functions. For instance if I had a fancy table widget I'd have a function called initTable() that contained the behaviour code. I'd call it initially upon page load, then call it again when necessary if content has been updated via ajax. [...]

[jQuery] Best practices for reattaching behaviours to dynamically loaded content?

2007-03-04 Thread Nedjo Rogers
As site developers using jQuery, we often attach jQuery behaviours through an attach function that's registered with $(document).ready();. Typically, behaviours attach to content identified by jQuery selectors, e.g., id or class values. This works great for the initial DOM ready state. But how

Re: [jQuery] Best practices for reattaching behaviours to dynamically loaded content?

2007-03-04 Thread Felix Geisendörfer
I found that the simplest way to handle all of this is to make use of the context parameter of jQuery. Basically write your attachBehaviors function like this: var attachBehaviors = function(context) { context = context || document; $('a', context).bind('click', ...); $('#product',

Re: [jQuery] Best practices for reattaching behaviours to dynamically loaded content?

2007-03-04 Thread Chris Domigan
I keep all my behaviours in separate functions. For instance if I had a fancy table widget I'd have a function called initTable() that contained the behaviour code. I'd call it initially upon page load, then call it again when necessary if content has been updated via ajax. Eg.

Re: [jQuery] Best practices for reattaching behaviours to dynamically loaded content?

2007-03-04 Thread Joan Piedra
I believe this is the easiest and simplest way to do it. On 3/4/07, Chris Domigan [EMAIL PROTECTED] wrote: I keep all my behaviours in separate functions. For instance if I had a fancy table widget I'd have a function called initTable() that contained the behaviour code. I'd call it initially