So I've just been getting into jquery, been reading some tutorials and I've found myself very confused to do with event delegation/rebinding

Basically:

User clicks "Show Users"
result is retrieved using jquery and is a HTML forms and placed into
<div id="listusers"></div>

Then when they click the submit button jquerys unable to catch the onclick event I think because it's an added element, so how would I go about this?

With jquery you can use .live() to attach a function to an event. The use of live allows you to define functions on elements, even if they are not available yet. My guess is you currently use bind(), which only attaches to elements currently in the DOM.

Thank you very much this solved my entire problem I am so happy! :)

With jquery you can use .live() to attach a function to an event. The use of live allows you to define functions on elements, even if they are not available yet. My guess is you currently use bind(), which only attaches to elements currently in the DOM.

I signed up just to say thank you. This Advice was extremely helpful. Thank you very much!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.