From 698efb3039529fa26d8a769dc5e5a536d00fd233 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 4 Dec 2013 00:15:50 +0000 Subject: [PATCH] Better handling of submitting with passed button to properly process the button ID into the value array. Fixes the case where ID like 'button[delete]', previously wound up in button.button[delete]. --- etemplate/js/etemplate2.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/etemplate/js/etemplate2.js b/etemplate/js/etemplate2.js index 8ad50c5496..706f3f0bc4 100644 --- a/etemplate/js/etemplate2.js +++ b/etemplate/js/etemplate2.js @@ -392,7 +392,7 @@ etemplate2.prototype.submit = function(button, async) // I'm just not sure how. if(button && !values.button) { - values.button = button.id; + values.button = {}; var path = button.getPath(); var target = values; for(var i = 0; i < path.length; i++) @@ -400,7 +400,7 @@ etemplate2.prototype.submit = function(button, async) if(!values[path[i]]) values[path[i]] = {}; target = values[path[i]]; } - if(target != values) + if(target != values || button.id.indexOf('[') != -1 && path.length == 0) { var indexes = button.id.split('['); if (indexes.length > 1) @@ -421,6 +421,10 @@ etemplate2.prototype.submit = function(button, async) target = target[idx]; } } + else if (typeof values.button == 'undefined') + { + values.button = button.id; + } } // Create the request object