$(function() { $( "#add-form" ).dialog({ autoOpen: false, height: 900, width: 600, modal: true, buttons: { "New Shipment": function() { var thisShipmentInputs = $('#ShipmentAddForm').find('input,select,textarea'); $.post('/shipments/ajax_add', thisShipmentInputs, function(data) { $( "#add-form" ).dialog('close'); window.location.reload(); //Change this to fetch a new copy of the table and update a
. }); }, Cancel: function() { $( this ).dialog( "close" ); //$("#ShipmentAddForm")[0].reset(); $("#principlesList").empty(); } }, close: function() { $("#importFields").hide(); $("#principle").hide(); } }); $( "#edit-form" ).dialog({ autoOpen: false, height: 900, width: 600, modal: true, buttons: { "Save Shipment": function() { var thisShipmentInputs = $('#ShipmentEditForm').find('input,select,textarea'); $.post('/shipments/ajax_edit', thisShipmentInputs, function(data) { $( "#edit-form" ).dialog('close'); // window.location.reload(); //Change this to fetch a new copy of the table and update a
. }); }, Cancel: function() { $( this ).dialog( "close" ); //$("#ShipmentEditForm")[0].reset(); $("#principlesList").empty(); } }, close: function() { $("#importFields").hide(); $("#principle").hide(); } }); $( ".newShipment" ).button().click(function() { $.get('/shipments/add/', false, function(data) { $("#add-form").html(data); $( "#add-form" ).dialog( "open" ); } ); }); $(".editButton").button().click(function() { var id = $(this).attr('id'); $.get('/shipments/edit/'+id, false, function(data) { $("#edit-form").html(data); $( "#edit-form" ).dialog( "open" ); } ); }); });