JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://www.jeasyui.com/easyui/themes/default/easyui.css">
<link rel="stylesheet" href="http://www.jeasyui.com/easyui/themes/icon.css">
<script src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
<div>
Enter name: <input id="nameTB" type="text">
</div>
JavaScript
var neverEndingLoopStopper = 20;
$(function(){
$('#nameTB').textbox({
width: 90,
value: 'ng1',
onChange: function(newValue, oldValue) {
console.log('onchange fired...textbox, newValue:'+newValue+";oldValue:"+oldValue);
saveField($(this).textbox('getText'), function(){
console.log('reseting textbox to oldValue:'+oldValue);
$('#nameTB').textbox('initValue',oldValue);
});
}
});
});
function saveField(fieldValue, resetFN) {
console.log('db error occured while saving.. call reset function..');
if(neverEndingLoopStopper > 0) {
neverEndingLoopStopper--;
resetFN();
}
}