Re: [jQuery] Re: Attaching an event to a non-existing element?

2009-12-24 Thread Octavian Râşniţă

From: MorningZ morni...@gmail.com
.live() to the rescue

http://docs.jquery.com/Events/live#typefn



Thank you, but here is what I read about it:

Possible event values: click, dblclick, mousedown, mouseup, mousemove, 
mouseover, mouseout, keydown, keypress, keyup

Currently not supported: blur, focus, mouseenter, mouseleave, change, submit

I want to attach an event to a combo box that should be fired when the user 
double-clicks on it, or clicks on an element of that combo, or selects an 
element from the keyboard but I think I would need the change event which 
is not supported.
The click event works, but I think it would be fired before the user will 
reach to choose the wanted element. The double click is listed as supported, 
but I couldn't make it work.


Thank you.

Octavian






Re: [jQuery] Re: Attaching an event to a non-existing element?

2009-12-24 Thread Octavian Râsnita

From: Sime Vidas sime.vi...@gmail.com

Second, I haven't heard the term combo box in relation to HTML
you mean a SELECT element, right?


Yes.


To answer your question, I don't see why you couldn't attach the event
handler after the AJAX response

1. You get the AJAX response
2. You create the combo box
3. You append it to the DOM
4. You attach an event handler to it



Aha, probably I would need to learn a little more.

I have done it this way:

1. I created the AJAX request
2. I received the AJAX response in JSON format, and the content of the 
response contains the full HTML code for creating the select element 
starting with select... and ending with /select.

3. I have set this response as the content of an empty div.

That select element appears well, but maybe it doesn't appear as a DOM 
member, so that's why I can't attach an event handler to it.


Octavian