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].

This commit is contained in:
Nathan Gray 2013-12-04 00:15:50 +00:00
parent 7148a1f274
commit 698efb3039

View File

@ -392,7 +392,7 @@ etemplate2.prototype.submit = function(button, async)
// I'm just not sure how. // I'm just not sure how.
if(button && !values.button) if(button && !values.button)
{ {
values.button = button.id; values.button = {};
var path = button.getPath(); var path = button.getPath();
var target = values; var target = values;
for(var i = 0; i < path.length; i++) 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]] = {}; if(!values[path[i]]) values[path[i]] = {};
target = 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('['); var indexes = button.id.split('[');
if (indexes.length > 1) if (indexes.length > 1)
@ -421,6 +421,10 @@ etemplate2.prototype.submit = function(button, async)
target = target[idx]; target = target[idx];
} }
} }
else if (typeof values.button == 'undefined')
{
values.button = button.id;
}
} }
// Create the request object // Create the request object