postUrl = '/domains'; makeEditable('.domain-edit', domainUpdate, postUrl); function domainUpdate(newVal, prevVal, tr) { var obj = { operation: 'upd' , new: newVal , old: prevVal }; return obj; } $('.add-btn').click(function() { var currRow = $(this).parent().parent(); var currDomain = $(currRow).children("td").eq(0).find('input').val(); if (currDomain.length < 1) { fadeInOut('#fieldempty'); } else { sendDomain(currDomain, appendRow, showError, currRow); } }); $('.delete-btn').click(function() { var hisTr = $(this).parent().parent(); var domain = $(hisTr).children("td").eq(0).text(); deleteDomain(domain, hisTr, removeRow, showError); }); $('.privileges-btn').click(function() { var hisTr = $(this).parent().parent(); var domain = $(hisTr).children("td").eq(0).text(); window.location = '/domain/' + domain + '/privileges'; }); function sendDomain(domainField, onSucc, onErr, addRow) { $.post( postUrl , { operation: "add", domain: domainField } ).done(function(data) { onSucc(domainField, addRow); }).fail(onErr); } function deleteDomain(domainField, row, onSucc, onErr) { $.post( postUrl , { operation: "del", domain: domainField } ).done(function(data) { onSucc(row); }).fail(onErr); } function appendRow(domainField, addRow) { fadeInOut("#updatesuccess"); $('#edittable tbody').append( '