Skip to content

Commit

Permalink
Merge pull request #2412 from meghaarora42/fix-multiselect-issue
Browse files Browse the repository at this point in the history
Change multiselect cache structure
  • Loading branch information
mshibuya committed Sep 28, 2015
2 parents c4ab2fe + 8afc20d commit 974b572
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/assets/javascripts/rails_admin/ra.filtering-multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@

this.element.find("option").each(function(i, option) {
if (option.selected) {
widget._cache[option.value] = option.innerHTML;
widget._cache['o_' + option.value] = {id: option.value, value: option.innerHTML};
$(option).clone().appendTo(widget.selection).attr("selected", false).attr("title", $(option).text());
} else {
widget._cache[option.value] = option.innerHTML;
widget._cache['o_' + option.value] = {id: option.value, value: option.innerHTML};
$(option).clone().appendTo(widget.collection).attr("selected", false).attr("title", $(option).text());
}
});
Expand All @@ -220,7 +220,8 @@
if (!this.options.xhr) {
for (i in this._cache) {
if (this._cache.hasOwnProperty(i)) {
matches.push({id: i, label: this._cache[i]});
option = this._cache[i];
matches.push({id: option.id, label: option.value});
}
}
success.apply(this, [matches]);
Expand All @@ -246,8 +247,9 @@
query = new RegExp(query + '.*', 'i');

for (i in this._cache) {
if (this._cache.hasOwnProperty(i) && query.test(this._cache[i])) {
matches.push({id: i, label: this._cache[i]});
if (this._cache.hasOwnProperty(i) && query.test(this._cache[i]['value'])) {
option = this._cache[i];
matches.push({id: option.id, label: option.value});
}
}

Expand Down

0 comments on commit 974b572

Please sign in to comment.