// add reset buttons and register their event handler
$('div.property').each(function () {
var key = $(this).find('input, textarea, select').attr('name');
var b = document.createElement('button');
$(b).addClass('reset');
$(b).attr('tabindex', '-1');
$(b).on('click', function () {
var initVal = $('form:eq(0)').uicForm3('initVal', key);
$('form:eq(0)').uicForm3('val', key, initVal);
});
var tn = document.createTextNode('reset');
b.appendChild(tn);
$(this).append(b);
});
// set defaults for uicForm3
$.fn.uicForm3.defaults = {
onPropertyModifiedStateChange: function (elements, name, initValue, currentValue, modified, e) {
if (modified === true) {
$(elements[0]).closest('div.property').addClass('modified');
$(elements[0]).closest('div.property').find('.reset').show();
} else {
$(elements[0]).closest('div.property').removeClass('modified');
$(elements[0]).closest('div.property').find('.reset').hide();
}
},
onFormModifiedStateChange: function (modified, e) {
if (modified === true) {
$('form:eq(0)').addClass('modified');
} else {
$('form:eq(0)').removeClass('modified');
}
},
onInitDataUnload: function(initialData, formModified) {
if (formModified) {
if (confirm('Do you want to dismiss the changes of the current recordset?')) {
return true;
}
return false;
}
return true;
}
}
// apply uicForm3 to the form
$('form:eq(0)').uicForm3();
var id = -1;
// register actions for the click event of the action buttons
$('#setInitialData').on('click', function (e) {
var d = data[0];
id = 0;
$('form:eq(0)').uicForm3('initData', d);
});
$('#prev').on('click', function (e) {
var num = Math.max(0, --id);
id = num;
var d = data[num];
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.