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

How to forcibly mark the form as dirty

Open TNBobbie opened this issue 8 years ago • 1 comments

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

TNBobbie avatar Oct 16 '17 19:10 TNBobbie

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).

jamgregory avatar Mar 25 '20 13:03 jamgregory