cmc-sales/webroot/js/document_attachments.js

67 lines
1.5 KiB
JavaScript
Raw Normal View History

2012-11-18 12:19:55 -08:00
$(function() {
var documentID = $("#documentID").html();
$("#addAttachment").click(function() {
$("#addAttachmentModal").dialog('open');
});
$("#addAttachmentModal").dialog({
autoOpen: false,
height: 900,
width: 600,
modal: true,
buttons: {
"Add Attachment": function() {
var attachmentInputs = $('#DocumentAttachmentAddForm').find('input');
$.post('/documents/saveAttachments', attachmentInputs, function(data) {
2012-12-01 18:17:09 -08:00
$("#addAttachmentModal").dialog( "close" );
2012-11-18 12:19:55 -08:00
});
2012-12-01 18:17:09 -08:00
2012-11-18 12:19:55 -08:00
},
Cancel: function() {
$( this ).dialog( "close" );
2012-12-01 18:17:09 -08:00
}
2012-11-18 12:19:55 -08:00
},
close: function() {
loadAttachments();
2012-12-01 18:17:09 -08:00
}
2012-11-18 12:19:55 -08:00
});
$("#attachmentPrincipleSelect").change(function() {
var principleID = $(this).val();
loadPrincipleAttachments(principleID);
});
2012-12-01 18:17:09 -08:00
$("#removeAttachments").click(function() {
removeAttachments();
});
2012-11-18 12:19:55 -08:00
function loadPrincipleAttachments(id) {
$.get('/documents/getAttachmentsByPrinciple/'+id, function(attachments) {
$('#principleAttachments').html(attachments);
});
}
function loadAttachments() {
$.get('/documents/getAttachments/'+documentID, function(attachments) {
2012-12-01 18:17:09 -08:00
$("#attachments-table").html(attachments);
2012-11-18 12:19:55 -08:00
});
2012-12-01 18:17:09 -08:00
}
function removeAttachments() {
var selectedAttachments = $(".documentAttachment-checkbox:checked");
$.post('/documents/removeAttachments', selectedAttachments, function(data) {
loadAttachments();
});
2012-11-18 12:19:55 -08:00
}
});