From beed5f35da168a96da1848b4c4839b14ee66175f Mon Sep 17 00:00:00 2001 From: Jonas Brusman Date: Wed, 13 Oct 2021 12:42:38 +0200 Subject: [PATCH] Force find all resources that the backend returns You can't disable the client side searching even when we do all search in the backend (selectize.js is stupid: selectize/selectize.js#1494), this will match all returned records, everytime. --- app/assets/javascripts/belongs_to_search.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/belongs_to_search.js b/app/assets/javascripts/belongs_to_search.js index 7ee0f18..96bf63a 100644 --- a/app/assets/javascripts/belongs_to_search.js +++ b/app/assets/javascripts/belongs_to_search.js @@ -5,7 +5,7 @@ $(function() { $element.selectize({ valueField: 'id', labelField: 'dashboard_display_name', - searchField: 'dashboard_display_name', + searchField: ['dashboard_display_name', 'searchField'], create: false, searchUrl: $element.data('url') + '?search=', @@ -19,7 +19,10 @@ $(function() { callback(); }, success: function(res) { - callback(res.resources); + callback(res.resources.map(function(resource){ + resource.searchField = query + return resource + })); } }); },