params can be a func, fixes #1
This commit is contained in:
@ -186,15 +186,22 @@ Editableform is linked with one of input types, e.g. 'text' or 'select'.
|
||||
|
||||
if (send) { //send to server
|
||||
this.showLoading();
|
||||
|
||||
//try parse json in single quotes
|
||||
this.options.params = $.fn.editableform.utils.tryParseJson(this.options.params, true);
|
||||
|
||||
params = $.extend({}, this.options.params, {
|
||||
|
||||
//standart params
|
||||
params = {
|
||||
name: this.options.name || '',
|
||||
value: value,
|
||||
pk: pk
|
||||
});
|
||||
};
|
||||
|
||||
//additional params
|
||||
if(typeof this.options.params === 'function') {
|
||||
$.extend(params, this.options.params.call(this, params));
|
||||
} else {
|
||||
//try parse json in single quotes (from data-params attribute)
|
||||
this.options.params = $.fn.editableform.utils.tryParseJson(this.options.params, true);
|
||||
$.extend(params, this.options.params);
|
||||
}
|
||||
|
||||
if(typeof this.options.url === 'function') { //user's function
|
||||
return this.options.url.call(this, params);
|
||||
@ -289,10 +296,14 @@ Editableform is linked with one of input types, e.g. 'text' or 'select'.
|
||||
**/
|
||||
url:null,
|
||||
/**
|
||||
Additional params for submit
|
||||
Additional params for submit. Function can be used to calculate params dynamically
|
||||
@example
|
||||
params: function() {
|
||||
return { a: 1 };
|
||||
}
|
||||
|
||||
@property params
|
||||
@type object
|
||||
@type object|function
|
||||
@default null
|
||||
**/
|
||||
params:null,
|
||||
@ -305,7 +316,8 @@ Editableform is linked with one of input types, e.g. 'text' or 'select'.
|
||||
**/
|
||||
name: null,
|
||||
/**
|
||||
Primary key of editable object (e.g. record id in database). Use Object for composite keys.
|
||||
Primary key of editable object (e.g. record id in database). For composite keys use object, e.g. <code>{id: 1, lang: 'en'}</code>.
|
||||
Can be calculated dinamically via function.
|
||||
|
||||
@property pk
|
||||
@type string|object|function
|
||||
|
Reference in New Issue
Block a user