added submitValue
to save
event params
This commit is contained in:
parent
90868b5bc1
commit
025c4c20cb
@ -3,6 +3,7 @@ X-editable changelog
|
|||||||
|
|
||||||
Version 1.4.5 wip
|
Version 1.4.5 wip
|
||||||
----------------------------
|
----------------------------
|
||||||
|
[enh] added `submitValue` to `save` event params (vitalets)
|
||||||
[enh #259] allow `getValue` method to return value itself, not object (vitalets)
|
[enh #259] allow `getValue` method to return value itself, not object (vitalets)
|
||||||
[enh] add `destroy` method to inputs (vitalets)
|
[enh] add `destroy` method to inputs (vitalets)
|
||||||
[enh #164] allow emptytext to be html (vitalets)
|
[enh #164] allow emptytext to be html (vitalets)
|
||||||
|
@ -212,8 +212,11 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//convert value for submitting to server
|
||||||
|
var submitValue = this.input.value2submit(newValue);
|
||||||
|
|
||||||
//sending data to server
|
//sending data to server
|
||||||
$.when(this.save(newValue))
|
$.when(this.save(submitValue))
|
||||||
.done($.proxy(function(response) {
|
.done($.proxy(function(response) {
|
||||||
//run success callback
|
//run success callback
|
||||||
var res = typeof this.options.success === 'function' ? this.options.success.call(this.options.scope, response, newValue) : null;
|
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
|
@event save
|
||||||
@param {Object} event event object
|
@param {Object} event event object
|
||||||
@param {Object} params additional params
|
@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
|
@param {Object} params.response ajax response
|
||||||
|
|
||||||
@example
|
@example
|
||||||
@ -254,7 +258,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
|
|||||||
if(params.newValue === 'username') {...}
|
if(params.newValue === 'username') {...}
|
||||||
});
|
});
|
||||||
**/
|
**/
|
||||||
this.$div.triggerHandler('save', {newValue: newValue, response: response});
|
this.$div.triggerHandler('save', {newValue: newValue, submitValue: submitValue, response: response});
|
||||||
}, this))
|
}, this))
|
||||||
.fail($.proxy(function(xhr) {
|
.fail($.proxy(function(xhr) {
|
||||||
var msg;
|
var msg;
|
||||||
@ -269,10 +273,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
|
|||||||
}, this));
|
}, this));
|
||||||
},
|
},
|
||||||
|
|
||||||
save: function(newValue) {
|
save: function(submitValue) {
|
||||||
//convert value for submitting to server
|
|
||||||
var submitValue = this.input.value2submit(newValue);
|
|
||||||
|
|
||||||
//try parse composite pk defined as json string in data-pk
|
//try parse composite pk defined as json string in data-pk
|
||||||
this.options.pk = $.fn.editableutils.tryParseJson(this.options.pk, true);
|
this.options.pk = $.fn.editableutils.tryParseJson(this.options.pk, true);
|
||||||
|
|
||||||
|
@ -150,12 +150,13 @@ $(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
asyncTest("event: save / hidden (reason: save)", function () {
|
asyncTest("event: save / hidden (reason: save)", function () {
|
||||||
expect(2);
|
expect(3);
|
||||||
var val = '1',
|
var val = '1',
|
||||||
e = $('<a href="#" data-pk="1" data-type="select" data-url="post.php" data-name="text" data-value="'+val+'"></a>').appendTo(fx);
|
e = $('<a href="#" data-pk="1" data-type="select" data-url="post.php" data-name="text" data-value="'+val+'"></a>').appendTo(fx);
|
||||||
|
|
||||||
e.on('save', function(event, params) {
|
e.on('save', function(event, params) {
|
||||||
equal(params.newValue, 2, 'save triggered, value correct');
|
equal(params.newValue, 2, 'save triggered, value correct');
|
||||||
|
equal(params.submitValue, '2', 'submitValue property correct');
|
||||||
});
|
});
|
||||||
|
|
||||||
e.on('hidden', function(event, reason) {
|
e.on('hidden', function(event, reason) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user