When server gives taglist options via ajax, take them all. Only filter local suggestions.

This commit is contained in:
Nathan Gray 2016-03-25 16:04:27 +00:00
parent 8105b93f80
commit 12ca409137
2 changed files with 13 additions and 9 deletions

View File

@ -267,8 +267,8 @@ var et2_taglist = (function(){ "use strict"; return et2_selectbox.extend([et2_IR
if(this.options.autocomplete_url && !jQuery.isEmptyObject(this.options.select_options))
{
var widget = this;
this.taglist.setData(function(query) {
return widget._data.call(widget,query);
this.taglist.setData(function(query, cfg) {
return widget._data.call(widget,query, cfg);
});
}
@ -420,9 +420,10 @@ var et2_taglist = (function(){ "use strict"; return et2_selectbox.extend([et2_IR
* typed, or query via AJAX if user typed something
*
* @param {string} query
* @param {Object} cfg Magicsuggest's internal configuration
* @returns {Array}
*/
_data: function(query) {
_data: function(query, cfg) {
var return_value = this.options.select_options || {};
@ -446,10 +447,13 @@ var et2_taglist = (function(){ "use strict"; return et2_selectbox.extend([et2_IR
else if (query.trim().length >= this.taglist_options.minChars || this._query_server)
{
// No options - ask server
return this.options.autocomplete_url;
return_value = this.options.autocomplete_url;
}
this._query_server = false;
// Turn on local filtering, or trust server to do it
cfg.mode = typeof return_value === 'string' ? 'remote' : 'local'
return return_value;
},
@ -519,8 +523,8 @@ var et2_taglist = (function(){ "use strict"; return et2_selectbox.extend([et2_IR
if(this.taglist == null || !source) return;
var widget = this;
this.taglist.setData(function(query) {
return widget._data.call(widget,query);
this.taglist.setData(function(query, cfg) {
return widget._data.call(widget,query, cfg);
});
}
},
@ -551,8 +555,8 @@ var et2_taglist = (function(){ "use strict"; return et2_selectbox.extend([et2_IR
if(this.taglist == null) return;
var widget = this;
this.taglist.setData(function(query) {
return widget._data.call(widget,query);
this.taglist.setData(function(query, cfg) {
return widget._data.call(widget,query, cfg);
});
},

View File

@ -823,7 +823,7 @@
var json = null, data = source || cfg.data;
if(data !== null) {
if(typeof(data) === 'function'){
data = data.call(ms, ms.getRawValue());
data = data.call(ms, ms.getRawValue(),cfg);
}
if(typeof(data) === 'string') { // get results from ajax
$(ms).trigger('beforeload', [ms]);