diff --git a/src/js/bootstrap-editable.js b/src/js/bootstrap-editable.js
index 559c358..62633e1 100644
--- a/src/js/bootstrap-editable.js
+++ b/src/js/bootstrap-editable.js
@@ -431,7 +431,7 @@
if(!$(document).data(cacheID)) $(document).data(cacheID, {});
cache = $(document).data(cacheID);
-
+
//check for cached data
if (cache.loading === false && cache.source && typeof cache.source === 'object') { //take source from cache
this.settings.source = cache.source;
@@ -447,7 +447,7 @@
cache.loading = true;
cache.callbacks = [];
}
-
+
//options loading from server
$.ajax({
url: this.settings.source,
diff --git a/test/select.js b/test/select.js
index ee642d8..0f0ecb7 100644
--- a/test/select.js
+++ b/test/select.js
@@ -229,7 +229,7 @@ $(function () {
}, timeout);
});
- asyncTest("cache options request for same selects", function () {
+ asyncTest("cache request for same selects", function () {
var e = $('customer').appendTo(fx).editable(),
e1 = $('customer').appendTo(fx).editable(),
req = 0;
@@ -273,6 +273,39 @@ $(function () {
});
+ asyncTest("cache simultaneous requests", function () {
+ expect(4);
+ var req = 0;
+ $.mockjax({
+ url: 'groups-cache-sim.php',
+ responseTime: 200,
+ response: function() {
+ req++;
+ this.responseText = groups;
+ }
+ });
+
+ var e = $('35').appendTo(fx).editable(),
+ e1 = $('35').appendTo(fx).editable(),
+ e2 = $('6456').appendTo(fx).editable();
+
+ setTimeout(function() {
+
+ equal(req, 1, 'one request');
+ equal(e.text(), groups[1], 'text1 correct');
+ equal(e1.text(), groups[2], 'text2 correct');
+ equal(e2.text(), groups[3], 'text3 correct');
+
+ e.remove();
+ e1.remove();
+ e2.remove();
+ start();
+ }, 300);
+
+ });
+
+
+
test("autotext: auto", function () {
expect(3);
//auto, text->empty, source->array