name not appended to source url, fixes #53
This commit is contained in:
parent
4109609e63
commit
94cee0731a
@ -4,6 +4,7 @@ X-editable changelog
|
||||
|
||||
Version 1.3.1 wip
|
||||
----------------------------
|
||||
[enh #53] 'name' no more appended to source defined as url (vitalets)
|
||||
[enh #46] move 'img' dir outside 'css' (vitalets)
|
||||
[enh #48] fix handling of newlines in textarea input (jmfontaine)
|
||||
[enh #47] set select source to function (brianchance)
|
||||
|
@ -73,7 +73,7 @@ List - abstract class for inputs that have source option loaded from js array or
|
||||
if (typeof this.options.source === 'string') {
|
||||
//try to get from cache
|
||||
if(this.options.sourceCache) {
|
||||
var cacheID = this.options.source + (this.options.name ? '-' + this.options.name : ''),
|
||||
var cacheID = this.options.source,
|
||||
cache;
|
||||
|
||||
if (!$(document).data(cacheID)) {
|
||||
@ -84,11 +84,13 @@ List - abstract class for inputs that have source option loaded from js array or
|
||||
//check for cached data
|
||||
if (cache.loading === false && cache.sourceData) { //take source from cache
|
||||
this.sourceData = cache.sourceData;
|
||||
this.doPrepend();
|
||||
success.call(this);
|
||||
return;
|
||||
} else if (cache.loading === true) { //cache is loading, put callback in stack to be called later
|
||||
cache.callbacks.push($.proxy(function () {
|
||||
this.sourceData = cache.sourceData;
|
||||
this.doPrepend();
|
||||
success.call(this);
|
||||
}, this));
|
||||
|
||||
@ -107,7 +109,6 @@ List - abstract class for inputs that have source option loaded from js array or
|
||||
url: this.options.source,
|
||||
type: 'get',
|
||||
cache: false,
|
||||
data: this.options.name ? {name: this.options.name} : {},
|
||||
dataType: 'json',
|
||||
success: $.proxy(function (data) {
|
||||
if(cache) {
|
||||
@ -115,17 +116,19 @@ List - abstract class for inputs that have source option loaded from js array or
|
||||
}
|
||||
this.sourceData = this.makeArray(data);
|
||||
if($.isArray(this.sourceData)) {
|
||||
this.doPrepend();
|
||||
success.call(this);
|
||||
if(cache) {
|
||||
//store result in cache
|
||||
cache.sourceData = this.sourceData;
|
||||
$.each(cache.callbacks, function () { this.call(); }); //run success callbacks for other fields
|
||||
//run success callbacks for other fields waiting for this source
|
||||
$.each(cache.callbacks, function () { this.call(); });
|
||||
}
|
||||
this.doPrepend();
|
||||
success.call(this);
|
||||
} else {
|
||||
error.call(this);
|
||||
if(cache) {
|
||||
$.each(cache.err_callbacks, function () { this.call(); }); //run error callbacks for other fields
|
||||
//run error callbacks for other fields waiting for this source
|
||||
$.each(cache.err_callbacks, function () { this.call(); });
|
||||
}
|
||||
}
|
||||
}, this),
|
||||
|
@ -19,7 +19,10 @@ $(function () {
|
||||
})
|
||||
|
||||
asyncTest("load options from server", function () {
|
||||
var e = $('<a href="#" data-type="select" data-name="load-srv" data-value="2" data-source="groups.php">customer</a>').appendTo(fx).editable();
|
||||
var e = $('<a href="#" data-type="select" data-name="load-srv" data-value="2" data-source="groups.php">customer</a>').appendTo(fx).editable({
|
||||
//need to disable cache to force request
|
||||
sourceCache: false
|
||||
});
|
||||
|
||||
e.click();
|
||||
var p = tip(e);
|
||||
@ -265,7 +268,7 @@ $(function () {
|
||||
|
||||
asyncTest("cache request for same selects", function () {
|
||||
//clear cache
|
||||
$(document).removeData('groups.php-name1');
|
||||
$(document).removeData('groups.php');
|
||||
|
||||
var e = $('<a href="#" data-type="select" data-pk="1" data-name="name1" data-value="2" data-url="post.php" data-source="groups-cache.php">customer</a>').appendTo(fx).editable(),
|
||||
e1 = $('<a href="#" data-type="select" data-pk="1" id="name1" data-value="2" data-url="post.php" data-source="groups-cache.php">customer</a>').appendTo(fx).editable(),
|
||||
@ -314,7 +317,7 @@ $(function () {
|
||||
expect(4);
|
||||
|
||||
//clear cache
|
||||
$(document).removeData('groups-cache-sim.php-name1');
|
||||
$(document).removeData('groups-cache-sim.php');
|
||||
|
||||
var req = 0;
|
||||
$.mockjax({
|
||||
@ -348,7 +351,7 @@ $(function () {
|
||||
expect(4);
|
||||
|
||||
//clear cache
|
||||
$(document).removeData('groups-cache-sim-err.php-name1');
|
||||
$(document).removeData('groups-cache-sim-err.php');
|
||||
|
||||
var req = 0;
|
||||
$.mockjax({
|
||||
|
Loading…
x
Reference in New Issue
Block a user