sourceCache = false or source as function now trigger request on each show, fix , fix# 254

This commit is contained in:
vitalets
2013-06-13 08:51:58 +04:00
parent f8d8799fbc
commit 7daf7f09bc
5 changed files with 68 additions and 54 deletions

@ -181,8 +181,8 @@ Applied as jQuery method.
/*
Currently, form is re-rendered on every show.
The main reason is that we dont know, what container will do with content when closed:
remove(), detach() or just hide() - it depend on container.
The main reason is that we dont know, what will container do with content when closed:
remove(), detach() or just hide() - it depends on container.
Detaching form itself before hide and re-insert before show is good solution,
but visually it looks ugly --> container changes size before hide.

@ -59,7 +59,7 @@
*/
/*jshint laxcomma: true*/
setPosition: function () {
(function() {
var $tip = this.tip()
, inside

@ -58,30 +58,32 @@ List - abstract class for inputs that have source option loaded from js array or
// ------------- additional functions ------------
onSourceReady: function (success, error) {
//run source if it function
var source;
if ($.isFunction(this.options.source)) {
source = this.options.source.call(this.options.scope);
this.sourceData = null;
} else {
source = this.options.source;
}
//if allready loaded just call success
if($.isArray(this.sourceData)) {
if(this.options.sourceCache && $.isArray(this.sourceData)) {
success.call(this);
return;
}
// try parse json in single quotes (for double quotes jquery does automatically)
//try parse json in single quotes (for double quotes jquery does automatically)
try {
this.options.source = $.fn.editableutils.tryParseJson(this.options.source, false);
source = $.fn.editableutils.tryParseJson(source, false);
} catch (e) {
error.call(this);
return;
}
var source = this.options.source;
//run source if it function
if ($.isFunction(source)) {
source = source.call(this.options.scope);
}
//loading from url
if (typeof source === 'string') {
//try to get from cache
//try to get sourceData from cache
if(this.options.sourceCache) {
var cacheID = source,
cache;