I think you need the jQueryLive plugin. it allows you to bind events regardless of when they enter the dom. I wish there was a way to see the events that are attached, like in Firebug. Someone else might have a solution for that.
Glen On 10/16/07, Giovanni Battista Lenoci <[EMAIL PROTECTED]> wrote: > > > Hi, I have a doubt about the right way to perform an event binding. > > In a page a I have a select with id #cat1 and class="myselect". > > During the use of the page depending on the element selected on cat1 a > do an ajax call, that get a list of elements and generate a select > that has id="#cat{id_of_the_cat_selected}" and class "myselect". > > Now I want that #cat{id_of_the_cat_selected} be able to do the ajax > call, then In the success function of the ajax call I bind the event > to the object created. > In this way the interaction can be do with all cat on my tree. > > The first question is: > > Is the correct way to do this? > > I tried to bind the event in the document ready on the class > "myselect", but the event can't be bind on an element that not still > exist on the DOM. > > The other question is: > > In my specific case I use this script in two pages in my page, in the > second page I want that after the creation of the select another ajax > call get the element of the cat selected. > > For the first element no problem cause in document ready I attach to > bind 2 functions, but when the control passes to the function that > create the select the only function is binded is the one that creates > the select. > > I have to rewrite the function or I can in any mode attach another > event to the select created? > > How bind works, it add an event or overwrite the events with the ones > in the last call? > > There's a way to debug and see what events are attached to a > particular element? > > Sorry for my english, is not my spoken language and I did my best to > be clear.. :-) > > Thank you all > >