added submitValue to save event params

This commit is contained in:
vitalets
2013-06-15 20:19:07 +04:00
parent 90868b5bc1
commit 025c4c20cb
3 changed files with 11 additions and 8 deletions
CHANGELOG.txt
src/editable-form
test/unit

@ -212,8 +212,11 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
return;
}
//convert value for submitting to server
var submitValue = this.input.value2submit(newValue);
//sending data to server
$.when(this.save(newValue))
$.when(this.save(submitValue))
.done($.proxy(function(response) {
//run success callback
var res = typeof this.options.success === 'function' ? this.options.success.call(this.options.scope, response, newValue) : null;
@ -246,7 +249,8 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
@event save
@param {Object} event event object
@param {Object} params additional params
@param {mixed} params.newValue submitted value
@param {mixed} params.newValue raw new value
@param {mixed} params.submitValue submitted value as string
@param {Object} params.response ajax response
@example
@ -254,7 +258,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
if(params.newValue === 'username') {...}
});
**/
this.$div.triggerHandler('save', {newValue: newValue, response: response});
this.$div.triggerHandler('save', {newValue: newValue, submitValue: submitValue, response: response});
}, this))
.fail($.proxy(function(xhr) {
var msg;
@ -269,10 +273,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
}, this));
},
save: function(newValue) {
//convert value for submitting to server
var submitValue = this.input.value2submit(newValue);
save: function(submitValue) {
//try parse composite pk defined as json string in data-pk
this.options.pk = $.fn.editableutils.tryParseJson(this.options.pk, true);