www/js/profile_water.js

changeset 485
3cdfcdd71077
parent 286
124af734af68
child 494
af28ebe4a779
--- a/www/js/profile_water.js	Fri Sep 13 15:09:04 2019 +0200
+++ b/www/js/profile_water.js	Fri Sep 13 15:54:23 2019 +0200
@@ -44,9 +44,6 @@
 
 $(document).ready(function () {
 
-	var dataRecord = {};
-
-	var url = "includes/db_profile_water.php";
 	// tooltips
 	$("#name").jqxTooltip({ content: 'De unieke naam van dit water profiel.' });
 	$("#notes").jqxTooltip({ content: 'Extra opmerkingen over dit water.' });
@@ -59,8 +56,9 @@
 	$("#ph").jqxTooltip({ content: 'De zuurgraad (pH).' });
 	$("#total_alkalinity").jqxTooltip({ content: 'Totale alkaliniteit. Berekend meteen de Bicarbonaat.' });
 
-	// prepare the data
-	var source = {
+	var dataRecord = {},
+        url = 'includes/db_profile_water.php',
+	source = {
 		datatype: "json",
 		cache: false,
 		datafields: [
@@ -88,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);
@@ -106,6 +104,7 @@
 				type: "POST",
 				success: function (data, status, xhr) {
 					commit(true);
+					location.reload( true );
 				},
 				error: function(jqXHR, textStatus, errorThrown) {
                                         commit(false);
@@ -121,8 +120,8 @@
 				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);
@@ -142,8 +141,8 @@
 	$("#ph").jqxNumberInput( Spin2pH );
 	$("#total_alkalinity").jqxNumberInput( Spin1dec );
 
-	var dataAdapter = new $.jqx.dataAdapter(source);
-	var editrow = -1;
+	var dataAdapter = new $.jqx.dataAdapter(source),
+	editrow = -1;
 	// initialize jqxGrid
 	$("#jqxgrid").jqxGrid({
 		width: 1280,
@@ -193,7 +192,7 @@
 					editrow = row;
 					$("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } });
 					// get the clicked row's data and initialize the input fields.
-					var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow);
+					dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow);
 					$("#name").val(dataRecord.name);
 					$("#calcium").val(dataRecord.calcium);
 					$("#bicarbonate").val(dataRecord.bicarbonate);
@@ -273,7 +272,6 @@
 			$('#jqxgrid').jqxGrid('addrow', null, row);
 		}
 		$("#popupWindow").jqxWindow('hide');
-		location.reload( true );        // reload ourself.
 	});
 	createDelElements();
 });

mercurial