name not appended to source url, fixes #53
This commit is contained in:
@ -4,6 +4,7 @@ X-editable changelog
|
|||||||
|
|
||||||
Version 1.3.1 wip
|
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 #46] move 'img' dir outside 'css' (vitalets)
|
||||||
[enh #48] fix handling of newlines in textarea input (jmfontaine)
|
[enh #48] fix handling of newlines in textarea input (jmfontaine)
|
||||||
[enh #47] set select source to function (brianchance)
|
[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') {
|
if (typeof this.options.source === 'string') {
|
||||||
//try to get from cache
|
//try to get from cache
|
||||||
if(this.options.sourceCache) {
|
if(this.options.sourceCache) {
|
||||||
var cacheID = this.options.source + (this.options.name ? '-' + this.options.name : ''),
|
var cacheID = this.options.source,
|
||||||
cache;
|
cache;
|
||||||
|
|
||||||
if (!$(document).data(cacheID)) {
|
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
|
//check for cached data
|
||||||
if (cache.loading === false && cache.sourceData) { //take source from cache
|
if (cache.loading === false && cache.sourceData) { //take source from cache
|
||||||
this.sourceData = cache.sourceData;
|
this.sourceData = cache.sourceData;
|
||||||
|
this.doPrepend();
|
||||||
success.call(this);
|
success.call(this);
|
||||||
return;
|
return;
|
||||||
} else if (cache.loading === true) { //cache is loading, put callback in stack to be called later
|
} else if (cache.loading === true) { //cache is loading, put callback in stack to be called later
|
||||||
cache.callbacks.push($.proxy(function () {
|
cache.callbacks.push($.proxy(function () {
|
||||||
this.sourceData = cache.sourceData;
|
this.sourceData = cache.sourceData;
|
||||||
|
this.doPrepend();
|
||||||
success.call(this);
|
success.call(this);
|
||||||
}, this));
|
}, this));
|
||||||
|
|
||||||
@ -107,7 +109,6 @@ List - abstract class for inputs that have source option loaded from js array or
|
|||||||
url: this.options.source,
|
url: this.options.source,
|
||||||
type: 'get',
|
type: 'get',
|
||||||
cache: false,
|
cache: false,
|
||||||
data: this.options.name ? {name: this.options.name} : {},
|
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: $.proxy(function (data) {
|
success: $.proxy(function (data) {
|
||||||
if(cache) {
|
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);
|
this.sourceData = this.makeArray(data);
|
||||||
if($.isArray(this.sourceData)) {
|
if($.isArray(this.sourceData)) {
|
||||||
this.doPrepend();
|
|
||||||
success.call(this);
|
|
||||||
if(cache) {
|
if(cache) {
|
||||||
//store result in cache
|
//store result in cache
|
||||||
cache.sourceData = this.sourceData;
|
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 {
|
} else {
|
||||||
error.call(this);
|
error.call(this);
|
||||||
if(cache) {
|
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),
|
}, this),
|
||||||
|
@ -19,7 +19,10 @@ $(function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
asyncTest("load options from server", 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();
|
e.click();
|
||||||
var p = tip(e);
|
var p = tip(e);
|
||||||
@ -265,7 +268,7 @@ $(function () {
|
|||||||
|
|
||||||
asyncTest("cache request for same selects", function () {
|
asyncTest("cache request for same selects", function () {
|
||||||
//clear cache
|
//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(),
|
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(),
|
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);
|
expect(4);
|
||||||
|
|
||||||
//clear cache
|
//clear cache
|
||||||
$(document).removeData('groups-cache-sim.php-name1');
|
$(document).removeData('groups-cache-sim.php');
|
||||||
|
|
||||||
var req = 0;
|
var req = 0;
|
||||||
$.mockjax({
|
$.mockjax({
|
||||||
@ -348,7 +351,7 @@ $(function () {
|
|||||||
expect(4);
|
expect(4);
|
||||||
|
|
||||||
//clear cache
|
//clear cache
|
||||||
$(document).removeData('groups-cache-sim-err.php-name1');
|
$(document).removeData('groups-cache-sim-err.php');
|
||||||
|
|
||||||
var req = 0;
|
var req = 0;
|
||||||
$.mockjax({
|
$.mockjax({
|
||||||
|
Reference in New Issue
Block a user