Open 13ruce1337 opened 10 years ago
I've rediscovered the way to do undo in javascript:
//number of autosaves
var saves = [];
//arbitrary data from user
var data = $('#userinp');
//paragraph field declaration for ease
var para = $('p');
//function to show and put the text in the stack
function enTer(d) {
//value of input field
var f = d.val();
if(para.text() === null) {
$('p').text(f);
} else {
saves.push(para.text());
para.text(f);
}
}
//function to show the popped value from the stack
function unDo() {
var x = saves.pop();
$('p').text(x);
}
//click events
$('#enter').click(function(){enTer(data);});
$('#undo').click(function(){unDo();});
the only problem is I don't like how if this is implemented client side, every undo will trigger a query to the database. there has to be a more efficient way to accomplish this on the server side.
my thoughts are on a save button, but we all know thats how myth works and if the server is unavailable, you cannot save. this is what this page needs to overcome.
may have an idea of what we can do to
rollback()
changes...references:
PDO::beginTransaction()