$(function() { $(".addJob").button('enable'); $(".addJob").click(function() { $("#jobConfirm").dialog('open'); }); $( "#jobAddedDialog" ).dialog({ autoOpen: false, modal: true, buttons: { Ok: function() { $( this ).dialog( "close" ); } }, close: function(event,ui) { window.location.href = '/jobs'; } }); $( "#jobConfirm" ).dialog({ autoOpen: false, resizable: false, height:140, modal: true, buttons: { "Add new Job": function() { addJob(); $( this ).dialog( "close" ); }, Cancel: function() { $( this ).dialog( "close" ); } } }); function addJob() { var enquiryID = $(".addJob").attr("id"); $.post('/jobs/ajax_add/'+enquiryID, function(data) { $( "#jobAddedDialog" ).dialog('open'); }); } //Quote code below $(".addQuote").click(function() { window.location = '/documents/newDocument/quote/'+$( this ).attr('id'); }); $(".addInvoice").click(function() { if($("#jobsList > li").length == 0) { alert("Cant add an invoice! Add Invoice must be for a job. No jobs exist"); } else { $("#jobsList").show(); } }); });