ajaxOptions parameter
This commit is contained in:
@ -219,7 +219,7 @@ Editableform is linked with one of input types, e.g. 'text' or 'select'.
|
|||||||
save: function(value) {
|
save: function(value) {
|
||||||
var pk = (typeof this.options.pk === 'function') ? this.options.pk.call(this) : this.options.pk,
|
var pk = (typeof this.options.pk === 'function') ? this.options.pk.call(this) : this.options.pk,
|
||||||
send = !!(typeof this.options.url === 'function' || (this.options.url && ((this.options.send === 'always') || (this.options.send === 'auto' && pk)))),
|
send = !!(typeof this.options.url === 'function' || (this.options.url && ((this.options.send === 'always') || (this.options.send === 'auto' && pk)))),
|
||||||
params;
|
params, ajaxOptions;
|
||||||
|
|
||||||
if (send) { //send to server
|
if (send) { //send to server
|
||||||
this.showLoading();
|
this.showLoading();
|
||||||
@ -243,12 +243,14 @@ Editableform is linked with one of input types, e.g. 'text' or 'select'.
|
|||||||
if(typeof this.options.url === 'function') { //user's function
|
if(typeof this.options.url === 'function') { //user's function
|
||||||
return this.options.url.call(this, params);
|
return this.options.url.call(this, params);
|
||||||
} else { //send ajax to server and return deferred object
|
} else { //send ajax to server and return deferred object
|
||||||
return $.ajax({
|
ajaxOptions = $.extend({
|
||||||
url : this.options.url,
|
url : this.options.url,
|
||||||
data : params,
|
data : params,
|
||||||
type : 'post',
|
type : 'post',
|
||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
});
|
}, this.options.ajaxOptions);
|
||||||
|
|
||||||
|
return $.ajax(ajaxOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -420,7 +422,16 @@ Editableform is linked with one of input types, e.g. 'text' or 'select'.
|
|||||||
if(!response.success) return response.msg;
|
if(!response.success) return response.msg;
|
||||||
}
|
}
|
||||||
**/
|
**/
|
||||||
success: function(response, newValue) {}
|
success: function(response, newValue) {},
|
||||||
|
/**
|
||||||
|
Additional options for ajax request.
|
||||||
|
List of values: http://api.jquery.com/jQuery.ajax
|
||||||
|
|
||||||
|
@property ajaxOptions
|
||||||
|
@type object
|
||||||
|
@default null
|
||||||
|
**/
|
||||||
|
ajaxOptions: null
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -287,6 +287,9 @@ $(function () {
|
|||||||
equal(resp.data.name, 'username', 'name ok');
|
equal(resp.data.name, 'username', 'name ok');
|
||||||
equal(resp.data.value, newText, 'value ok');
|
equal(resp.data.value, newText, 'value ok');
|
||||||
equal(resp.data.q, 2, 'additional params ok');
|
equal(resp.data.q, 2, 'additional params ok');
|
||||||
|
},
|
||||||
|
ajaxOptions: {
|
||||||
|
headers: {"myHeader": "123"}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
newText = 'cd<e>;"'
|
newText = 'cd<e>;"'
|
||||||
@ -303,8 +306,38 @@ $(function () {
|
|||||||
start();
|
start();
|
||||||
}, timeout);
|
}, timeout);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
asyncTest("ajaxOptions", function () {
|
||||||
|
var e = $('<a href="#" data-pk="1" data-url="post-options.php">abc</a>').appendTo(fx).editable({
|
||||||
|
name: 'username',
|
||||||
|
ajaxOptions: {
|
||||||
|
dataType: 'html'
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
newText = 'cd<e>;"'
|
||||||
|
|
||||||
|
$.mockjax({
|
||||||
|
url: 'post-options.php',
|
||||||
|
response: function(settings) {
|
||||||
|
equal(settings.dataType, 'html', 'dataType key ok');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
e.click()
|
||||||
|
var p = tip(e);
|
||||||
|
|
||||||
|
ok(p.find('input[type=text]').length, 'input exists')
|
||||||
|
p.find('input').val(newText);
|
||||||
|
p.find('form').submit();
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
|
e.remove();
|
||||||
|
start();
|
||||||
|
}, timeout);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
asyncTest("submit to url defined as function", function () {
|
asyncTest("submit to url defined as function", function () {
|
||||||
expect(3);
|
expect(3);
|
||||||
|
Reference in New Issue
Block a user