Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New input fields #111

Open
albrahimx opened this issue Jun 26, 2016 · 2 comments
Open

New input fields #111

albrahimx opened this issue Jun 26, 2016 · 2 comments

Comments

@albrahimx
Copy link

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,

@nenad
Copy link

nenad commented Jul 1, 2016

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');

@ibmjm
Copy link

ibmjm commented Sep 28, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants