Skip to content
Advertisement

Fire a function on a element

I need to add a color picker to some input elements. I’m using:

$(".element").colorPicker(){ ... }

This works perfectly. The problem is that the page has a AJAX form, which – when submitted – will overwrite the previous form with a new one (new input fields etc). After that the colorPicker stops working.

So how can I fire that function to the newly created inputs too?

Advertisement

Answer

Just reattach the invocation in the ajax callback, since I don’t believe there is a reliable event you can use to .live or .delegate it, without revealing more information.

Advertisement