diff -r 06df1320327c -r 77f1617b6994 www/js/inv_suppliers.js --- a/www/js/inv_suppliers.js Fri Sep 13 16:54:51 2019 +0200 +++ b/www/js/inv_suppliers.js Fri Sep 13 20:24:31 2019 +0200 @@ -45,7 +45,7 @@ $(document).ready(function () { - var url = "includes/db_inventory_suppliers.php"; + // tooltips $("#name").jqxTooltip({ content: 'De naam van de leverancier.' }); $("#address").jqxTooltip({ content: 'Het adres en huisnummer.' }); @@ -56,8 +56,10 @@ $("#email").jqxTooltip({ content: 'Het email adres.' }); $("#phone").jqxTooltip({ content: 'Het telefoon nummer.' }); $("#notes").jqxTooltip({ content: 'Opmerkingen over deze leverancier.' }); + + var url = 'includes/db_inventory_suppliers.php', // prepare the data - var source = { + source = { datatype: "json", cache: false, datafields: [ @@ -84,8 +86,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); @@ -102,6 +104,7 @@ type: "POST", success: function (data, status, xhr) { commit(true); + location.reload( true ); }, error: function(jqXHR, textStatus, errorThrown) { commit(false); @@ -117,15 +120,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 }); $("#address").jqxInput({ theme: theme, width: 350, height: 23 }); @@ -137,8 +143,6 @@ $("#phone").jqxInput({ theme: theme, width: 175, height: 23 }); $("#notes").jqxInput({ theme: theme, width: 800, height: 100 }); - var dataAdapter = new $.jqx.dataAdapter(source); - var editrow = -1; // initialize jqxGrid $("#jqxgrid").jqxGrid({ width: 1280, @@ -147,8 +151,8 @@ theme: theme, showstatusbar: true, renderstatusbar: function (statusbar) { - var container = $("
"); - var addButton = $("
Nieuw
"); + var addButton, container = $("
"); + addButton = $("
Nieuw
"); container.append(addButton); statusbar.append(container); addButton.jqxButton({ theme: theme, width: 90, height: 20 }); @@ -175,8 +179,9 @@ { text: 'Plaats', datafield: 'city', width: 250 }, { text: 'Land', datafield: 'country', width: 200 }, { text: 'Telefoon', datafield: 'phone', width: 175 }, - { text: 'Wijzig', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function () { - return "Wijzig"; + { text: 'Wijzig', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', + cellsrenderer: function () { + return "Wijzig"; }, buttonclick: function (row) { // open the popup window when the user clicks a button. editrow = row; @@ -228,11 +233,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(), address: $("#address").val(), @@ -250,7 +255,6 @@ $('#jqxgrid').jqxGrid('addrow', null, row); } $("#popupWindow").jqxWindow('hide'); - location.reload( true ); // reload ourself. }); createDelElements(); });