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

How to forcibly mark the form as dirty #134

Open
TNBobbie opened this issue Oct 16, 2017 · 1 comment
Open

How to forcibly mark the form as dirty #134

TNBobbie opened this issue Oct 16, 2017 · 1 comment

Comments

@TNBobbie
Copy link

Hello,

I have a form loaded which is clean. Now, due to certain conditions, up on clicking a button, the entire page reloads with some additional text boxes on the page. At this point, is there a way to treat it as dirty & raise the popup?

I tried using the following, but that doesn't seem to do the trick.
$('#aspnetForm').trigger('checkform.areYouSure');
$('#aspnetForm').trigger('rescan.areYouSure');

Thanks
Bobby

@jamgregory
Copy link

I expect you might not need this now @TNBobbie (it is over 3 years late!) but just in case anyone else comes across this issue, you can do something like this:

setTimeout(function(){
  $('#aspnetForm').toggleClass('dirty', true);
}, 10);

I chose to wrap it in a setTimeout just in case areYouSure wiped out the dirty class before we got round to setting it (it doesn't work if you initialise the form with the dirty class set, for example).

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

2 participants