diff -r 06df1320327c -r 77f1617b6994 www/js/inv_fermentables.js --- a/www/js/inv_fermentables.js Fri Sep 13 16:54:51 2019 +0200 +++ b/www/js/inv_fermentables.js Fri Sep 13 20:24:31 2019 +0200 @@ -44,16 +44,15 @@ $(document).ready(function () { - var dataRecord = {}; - function calcTotal(cost, inventory) { $('#totval').val(cost * inventory); } - var url = "includes/db_inventory_fermentables.php"; + var dataRecord = {}, + url = 'includes/db_inventory_fermentables.php', // prepare the data - var source = { + source = { datatype: "json", cache: false, datafields: [ @@ -95,8 +94,8 @@ data: data, type: "POST", success: function (data, status, xhr) { - // delete command is executed. commit(true); + location.reload( true ); }, error: function (jqXHR, textStatus, errorThrown) { commit(false); @@ -113,6 +112,7 @@ type: "POST", success: function (data, status, xhr) { commit(true); + location.reload( true ); }, error: function(jqXHR, textStatus, errorThrown) { commit(false); @@ -128,15 +128,18 @@ data: data, type: "POST", success: function (data, status, xhr) { - // update command is executed. commit(true); + location.reload( true ); }, error: function(jqXHR, textStatus, errorThrown) { commit(false); } }); } - }; + }, + dataAdapter = new $.jqx.dataAdapter(source), + editrow = -1; + // initialize the input fields. $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); $("#type").jqxDropDownList({ @@ -188,8 +191,6 @@ $("#tht_date").jqxDateTimeInput( Dateopts ); $("#totval").jqxNumberInput( Show2dec ); - var dataAdapter = new $.jqx.dataAdapter(source); - var editrow = -1; // initialize jqxGrid $("#jqxgrid").jqxGrid({ width: 1280, @@ -198,9 +199,10 @@ theme: theme, showstatusbar: true, renderstatusbar: function (statusbar) { - var container = $("
"); - var addButton = $("
Nieuw
"); - var impButton = $("
Import
"); + var container, addButton, impButton; + container = $("
"); + addButton = $("
Nieuw
"); + impButton = $("
Import
"); container.append(addButton); container.append(impButton); statusbar.append(container); @@ -237,8 +239,7 @@ $("#popupWindow").jqxWindow('open'); }); impButton.click(function (event) { - var url="import_ingredients.php?select=fermentables"; - window.location.href = url; + window.location.href = 'import_ingredients.php?select=fermentables'; }); }, filterable: true, @@ -271,8 +272,9 @@ return "" + amount + ""; } }, - { text: '', datafield: 'Edit', width: 100, align: 'center', menu: false, columntype: 'button', cellsrenderer: function () { - return "Wijzig"; + { text: '', datafield: 'Edit', width: 100, align: 'center', menu: false, columntype: 'button', + cellsrenderer: function () { + return "Wijzig"; }, buttonclick: function (row) { // open the popup window when the user clicks a button. editrow = row; @@ -375,20 +377,18 @@ cost: parseFloat($('#cost').jqxNumberInput('decimal')), production_date: '', tht_date: '' - }; $('#jqxgrid').jqxGrid('addrow', null, row); $('#popupWindow').jqxWindow('hide'); - location.reload( true ); // reload ourself. }); $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); // update the edited row when the user clicks the 'Save' button. $("#Save").click(function() { - var rowID = -1; + var row, rowID = -1; if (editrow >= 0) { rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); } - var row = { + row = { record: rowID, name: $("#name").val(), type: $("#type").val(), @@ -419,7 +419,6 @@ $('#jqxgrid').jqxGrid('updaterow', rowID, row); } else { $('#jqxgrid').jqxGrid('addrow', null, row); - location.reload( true ); // reload ourself. } $("#popupWindow").jqxWindow('hide'); });