jquery.AreYouSure icon indicating copy to clipboard operation
jquery.AreYouSure copied to clipboard

New input fields

Open albrahimx opened this issue 9 years ago • 2 comments

Hello,

Thank you for the code!

I have a problem when applying this code. It works perfectly fine with the fields that is already written in the HTML. But, I have a form that allows the user to add a new input field by using JavaScript. The problem is that it doesn't check the new input fields added by JavaScript.

Is there a way to make this code work with the new added fields?

Many thanks,

albrahimx avatar Jun 26 '16 20:06 albrahimx

Yes, it's included in the documentation:

/*
*  If you're dynamically adding new fields/inputs, and would like to track 
*  their state, trigger Are-You-Sure to rescan the form like this:
*/
$('#my-form').trigger('rescan.areYouSure');

nenad avatar Jul 01 '16 13:07 nenad

As far as I can tell (from experimentation), doing $('#my-form').trigger('rescan.areYouSure'); will reset the "dirty" flag on the form, which isn't necessarily what is wanted.

For example, I might have a checkbox which the user checks (marking the form as dirty), and a button which the user then clicks to add a file-upload control to the form dynamically. If I rescan as suggested, it seems to reset the form to clean.

I am open to being proven wrong but that's what seemed to be happening to me.

ibmjm avatar Sep 28 '16 20:09 ibmjm