How to forcibly mark the form as dirty
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
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).