Want to change elements data before it goes to the server.
Want to change elements data before it goes to the server.
I have looked at several examples using
editor.on('preSubmit', function(e, o, action)
but I am having problems selecting the element in the out going data array. The following is my function.
editor.on('preSubmit', function(e, o, action) {
if (action == 'edit') {
var testParameters = editor.field('t.test_parameters');
if (testParameters != null ){
console.log("tp: " + testParameters.val());
var temp = testParameters.val().split("=").join("/");//replace all = with /.
console.log("temp: " + temp);
//editor.field('t.test_parameters' ).val(temp);
o.data.test_parameters = temp ;
console.log(o);
}
}
});
Everything is just fine at the beginning where I get the editor's field. testParameters is populated properly. I then alter the data and that is fine. I want to update the same field but
o.data.test_parameters = temp ;
adds an element to the data array. Stupid me I tried the following
o.data.t.test_parameters = temp ;
but this does not work because this is not the right syntax to update the element. Would somebody be so kind and tell me how I should update the t.test_parameters value in the o.data array. Help would be much appreciated.
This question has an accepted answers - jump to answer
Answers
I expanded my search and found the following link
I changed my code in the editor.on('preSubmit') so that it uses the following code.
This works just fine. Hope this helps others. Please close.
Hi,
Good to hear you found the solution. The loop is required because of Editor 1.5's multi-row editing ability. The data format is detailed in the client / server communication documentation.
Allan