diff -r 06df1320327c -r 77f1617b6994 www/js/inv_miscs.js --- a/www/js/inv_miscs.js Fri Sep 13 16:54:51 2019 +0200 +++ b/www/js/inv_miscs.js Fri Sep 13 20:24:31 2019 +0200 @@ -42,8 +42,6 @@ $(document).ready(function () { - var dataRecord = {}; - function calcTotal(cost, inventory) { $('#totval').val(cost * (inventory / 1000)); @@ -60,9 +58,10 @@ } } - var url = "includes/db_inventory_miscs.php"; + var dataRecord = {}, + url = 'includes/db_inventory_miscs.php', // prepare the data - var source = { + source = { datatype: "json", cache: false, datafields: [ @@ -93,8 +92,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); @@ -111,6 +110,7 @@ type: "POST", success: function (data, status, xhr) { commit(true); + location.reload( true ); }, error: function(jqXHR, textStatus, errorThrown) { commit(false); @@ -126,15 +126,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 }); $("#notes").jqxInput({ theme: theme, width: 800, height: 100 }); @@ -166,8 +169,6 @@ $("#tht_date").jqxDateTimeInput( Dateopts ); $("#totval").jqxNumberInput( Show2dec ); - var dataAdapter = new $.jqx.dataAdapter(source); - var editrow = -1; // initialize jqxGrid $("#jqxgrid").jqxGrid({ width: 1280, @@ -176,9 +177,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); @@ -203,8 +205,7 @@ $("#popupWindow").jqxWindow('open'); }); impButton.click(function (event) { - var url="import_ingredients.php?select=miscs"; - window.location.href = url; + window.location.href = 'import_ingredients.php?select=miscs'; }); }, filterable: true, @@ -254,8 +255,9 @@ } }, { text: 'THT datum', datafield: 'tht_date', width: 100, menu: false, align: 'center', cellsalign: 'center' }, - { text: '', datafield: 'Edit', columntype: 'button', width: 100, menu: false, align: 'center', cellsrenderer: function () { - return "Wijzig"; + { text: '', datafield: 'Edit', columntype: 'button', width: 100, menu: false, align: 'center', + cellsrenderer: function () { + return "Wijzig"; }, buttonclick: function (row) { // open the popup window when the user clicks a button. editrow = row; @@ -330,11 +332,11 @@ $("#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(), @@ -353,7 +355,6 @@ $('#jqxgrid').jqxGrid('updaterow', rowID, row); } else { $('#jqxgrid').jqxGrid('addrow', null, row); - location.reload( true ); // reload ourself. } $("#popupWindow").jqxWindow('hide'); });