cmc-sales/webroot/js/document_attachments.js

65 lines
1.3 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) {
if(data == 'SUCCESS') {
loadAttachments();
$(this).dialog('close');
}
else {
alert("Attachments could not be saved")
}
});
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
close: function() {
loadAttachments();
}
});
$("#attachmentPrincipleSelect").change(function() {
var principleID = $(this).val();
loadPrincipleAttachments(principleID);
});
function loadPrincipleAttachments(id) {
$.get('/documents/getAttachmentsByPrinciple/'+id, function(attachments) {
$('#principleAttachments').html(attachments);
});
}
function loadAttachments() {
$.get('/documents/getAttachments/'+documentID, function(attachments) {
});
}
});