Javascript confirm message before setting custom options to defaults
-
First some background …
I got custom options working (displaying, saving, etc) just fine for a plugin (actually several) using the settings api.
Then I added a “Reset Defaults” button. I just check for a “Reset” in the validation callback and do my thing. Right now there’s a text message next to the Reset button warning that the options will be reset to defaults without further warning. That’s sorta sucky.
So just added a JavaScript Confirm dialog generated by the onClick Event on the reset button. I get a Yes/No back, set a hidden option field and that goes to the validation callback, which handles it. Got that working, no problems.
SO NOW, if the user selects “NO, don’t reset to defaults” on the JavaScript confirm dialog, I’d like to intercept/interrupt the call to options.php (the validation hook), do nothing, and just stay on the plugin’s custom settings screen without reloading the page.
Is there a way to do this either via a WordPress hook or some additional JavaScript?
Thanks in advance.
The topic ‘Javascript confirm message before setting custom options to defaults’ is closed to new replies.