I use jQueryUI's tabs and when a user changes a form in the tab, it promprts the user that a change has been made.
My question is, how do I revert the values before being changed when the user presses 'OK' on my confirm() prompt?
I use jQueryUI's tabs and when a user changes a form in the tab, it promprts the user that a change has been made.
My question is, how do I revert the values before being changed when the user presses 'OK' on my confirm() prompt?
You'll have to keep track of what the values were before changing them... so something like this should work for you:
var oldValues = {};
$(function() {
$(":input").each(function() {
oldValues[$(this).attr("id")] = $(this).val();
});
});
function revertValues() {
for (var oldVal in oldValues) {
$("#" + oldVal).val(oldValues[oldVal]);
}
}
And then just call revertValues
when you hit OK in your confirmation dialog.
A few notes:
:input
selector and keep different sets of oldValues
for each tab (& then obviously only revert the values for the current tab.