www/js/inv_yeasts.js

changeset 488
77f1617b6994
parent 481
fc21dcfbe51d
child 512
4451af8b6295
--- a/www/js/inv_yeasts.js	Fri Sep 13 16:54:51 2019 +0200
+++ b/www/js/inv_yeasts.js	Fri Sep 13 20:24:31 2019 +0200
@@ -44,8 +44,6 @@
 
 $(document).ready(function() {
 
-	var dataRecord = {};
-
 	function calcTotal() {
 
 		$('#totval').val(dataRecord.cost * dataRecord.inventory);
@@ -67,7 +65,8 @@
 		}
 	}
 
-	var url = 'includes/db_inventory_yeasts.php',
+	var dataRecord = {},
+	url = 'includes/db_inventory_yeasts.php',
 	source = {
 		datatype: 'json',
 		cache: false,
@@ -104,8 +103,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);
@@ -122,6 +121,7 @@
 				type: "POST",
 				success: function (data, status, xhr) {
 					commit(true);
+					location.reload( true );
 				},
 				error: function(jqXHR, textStatus, errorThrown) {
 					commit(false);
@@ -137,15 +137,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 });
 	$("#laboratory").jqxInput({ theme: theme, width: 320, height: 23 });
@@ -194,8 +197,6 @@
 	$("#tolerance").jqxNumberInput( Perc1dec );
 	$("#tolerance").jqxNumberInput({ max: 25 });
 
-	var dataAdapter = new $.jqx.dataAdapter(source),
-	editrow = -1;
 	// initialize jqxGrid
 	$("#jqxgrid").jqxGrid({
 		width: 1280,
@@ -390,7 +391,6 @@
 		};
 		$('#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.
@@ -428,7 +428,6 @@
 			$('#jqxgrid').jqxGrid('updaterow', rowID, row);
 		} else {
 			$('#jqxgrid').jqxGrid('addrow', null, row);
-			location.reload( true );	// reload ourself.
 		}
 		$("#popupWindow").jqxWindow('hide');
 	});

mercurial