changeset 650:1005de5ee3f0

Add nofail argument to jsMakePostArgs() to ignore unfound DOM elements.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 03 Nov 2014 04:08:31 +0200
parents a9d10fa6c890
children ad266a57eb23
files admin.js majax.inc.php
diffstat 2 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/admin.js	Mon Nov 03 03:39:01 2014 +0200
+++ b/admin.js	Mon Nov 03 04:08:31 2014 +0200
@@ -307,7 +307,7 @@
 
 function updateCompo(id)
 {
-  var args = jsMakePostArgs({"name":1, "description":1, "visible":3, "voting":3, "show_authors":3, "cpath":1}, "co", id);
+  var args = jsMakePostArgs({"name":1, "description":1, "visible":3, "voting":3, "show_authors":3, "cpath":1}, "co", id, true);
 
   var msuccess = function(txt)
   {
--- a/majax.inc.php	Mon Nov 03 03:39:01 2014 +0200
+++ b/majax.inc.php	Mon Nov 03 04:08:31 2014 +0200
@@ -157,7 +157,7 @@
 // for validity can be performed (e.g. field empty or not)
 //
 var lastPostArgs = Object();
-function jsMakePostArgs(fields, fprefix, fsuffix)
+function jsMakePostArgs(fields, fprefix, fsuffix, nofail)
 {
   var res = [];
   lastPostArgs = Object();
@@ -166,12 +166,13 @@
   {
     var elname = fprefix + id + fsuffix;
     var elem = document.getElementById(elname);
-    if (!elem)
+    if (!elem && !nofail)
     {
       jsMessageBox("No such DOM element '"+ elname +"'.");
       return "";
     }
 
+    if (elem)
     switch (fields[id])
     {
       case 1: