ruby on rails - Select tag with many items takes time to render -


i have form select tag containing 17k items.

<%= f.select :company_industry_id, options_for_select(@company_industries.map{  |c| [c.name, c.id] }, selected_key = @company.company_industry_id),  {}, {:class => 'input_text'} %> 

loading data @company_industries takes 0.01s.

@company_industries = companyindustry.select(:id, :name).order('name asc') 

however, rendering in f.select box takes 18 seconds (without having f.select element in form, page rendered in 350-400ms).

how avoid slowdown? there way optimize f.select element? or, there alternative f.select?

i suggest select2

and best approach not load data immediately, when user types in 3 letters, show data filtered 3 letters. gives nice way search trough 17k elements, faster find result.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -