/** * file: addpurchaseorder.js */ $(function() { $('#PurchaseOrderIssueDateDisplay').datepicker({ showButtonPanel: true, dateFormat: 'DD d MM yy', altFormat: 'yy-mm-dd', altField: '#PurchaseOrderIssueDate' }); $('#PurchaseOrderDispatchDateDisplay').datepicker({ showButtonPanel: true, dateFormat: 'DD d MM yy', altFormat: 'yy-mm-dd', altField: '#PurchaseOrderDispatchDate' }); $('#PurchaseOrderDateArrivedDisplay').datepicker({ showButtonPanel: true, dateFormat: 'DD d MM yy', altFormat: 'yy-mm-dd', altField: '#PurchaseOrderDateArrived' }); /** * A more generic way of handling the HABTM */ function addToList(modelName, id, value, ULelement) { var thisLI = $('
  • '); var thisButton = $(''); thisButton.addClass('removeFromList'); thisButton.button(); var thisHiddenInput = $(''); var modelString = '['+modelName+']'; thisHiddenInput.attr('name', 'data'+modelString+modelString+'[]'); thisHiddenInput.attr('value', id); thisLI.attr('id', modelName+'ID_'+id); thisLI.html(value); thisLI.prepend(thisButton); thisLI.append(thisHiddenInput); ULelement.append(thisLI); } });