2011-03-28 18:47:50 -07:00
|
|
|
$(function() {
|
2011-04-05 00:38:18 -07:00
|
|
|
|
2011-04-05 17:22:45 -07:00
|
|
|
// console.profile();
|
|
|
|
|
//$(":input").hide();
|
2011-04-05 00:38:18 -07:00
|
|
|
$(".editButton").show();
|
2011-04-05 17:22:45 -07:00
|
|
|
$(".cancelButton").hide();
|
|
|
|
|
$(".saveButton").hide();
|
2011-04-05 00:38:18 -07:00
|
|
|
|
2011-04-05 17:22:45 -07:00
|
|
|
$("input").attr("readonly","readonly");
|
|
|
|
|
$("select").attr("disabled", "disabled");
|
2011-04-05 00:38:18 -07:00
|
|
|
|
|
|
|
|
$(".editButton").click(function() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var id = $(this).parents('tr').attr('id');
|
|
|
|
|
//alert(id);
|
|
|
|
|
makeEditable(id);
|
|
|
|
|
|
2011-04-05 17:22:45 -07:00
|
|
|
$('.editButton').hide();
|
2011-04-05 00:38:18 -07:00
|
|
|
|
|
|
|
|
$("#"+id).find('.saveButton').show();
|
|
|
|
|
$("#"+id).find('.cancelButton').show();
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(".cancelButton").click(function() {
|
|
|
|
|
|
|
|
|
|
var id = $(this).parents('tr').attr('id');
|
|
|
|
|
$(this).hide();
|
|
|
|
|
$("#"+id).find('.saveButton').hide();
|
|
|
|
|
$("#"+id).find('.editButton').show();
|
|
|
|
|
cancelEditable(id);
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(".saveButton").click(function() {
|
|
|
|
|
var id = $(this).parents('tr').attr('id');
|
|
|
|
|
var serializedForm = $("#"+'form_'+id).serialize();
|
|
|
|
|
|
|
|
|
|
$.post('/jobs/ajax_edit', serializedForm, function(data) {
|
2011-04-05 17:22:45 -07:00
|
|
|
alert("Success! Job Edited"+data); //Need to do something here to update the Row.
|
|
|
|
|
window.location.reload();
|
2011-04-05 00:38:18 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//console.log($("#"+id).find('form').serialize());
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('form').submit(function() {
|
|
|
|
|
//console.log($(this).serialize());
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
2011-04-05 17:22:45 -07:00
|
|
|
//console.profileEnd();
|
2011-04-05 00:38:18 -07:00
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function makeEditable(id) {
|
2011-04-05 17:22:45 -07:00
|
|
|
$("#"+id).find('input').attr("readonly","");
|
|
|
|
|
$("#"+id).find('select').attr("disabled","");
|
2011-04-05 00:38:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function cancelEditable(id) {
|
2011-04-05 17:22:45 -07:00
|
|
|
$("#"+id).find('input').attr("readonly","readonly");
|
|
|
|
|
$("#"+id).find('select').attr("disabled","disabled");
|
2011-04-05 00:38:18 -07:00
|
|
|
$(".editButton").show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getParent() {
|
|
|
|
|
|
|
|
|
|
}
|