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.
[...]
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
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',
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.
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