simple form dropdown with search or autocomplete - ruby-on-rails

I have a simple form with a dropdown of items that it's very long. I would like to know if there is a way to make a search bar with an autocomplete for these items or a dropdown with a search bar that looks for items in the dropdown as you search.

You can also use the select2-rails gem to search from the dropdown.Here is the github link Click

I think your question is the same as the below question please check it. you can get a solution to your problem.
Ruby on Rails - Simple Form autocomplete association search

Related

Dynamic Search Field in Rails

I want to build a search field that give suggestions based on what the user is typing. Like the wikipedia search bar.
It should only query for the title names (not implementing any complex algo). What is the best way to do this with rails: gem and from scratch?
Use select2 jquery plugin. Its documentation is pretty cool as well. Visit https://select2.github.io/examples.html . Pass your collection to your form select box and call the class of it with select2. It will suggest the user according to the input.

Spree Commerce: display multiple categories on one page

I'm trying to make a link that can open or go to other page that display several categories on one page, like this: mugs, bags, and books
Is it possible to achieve this without using deface or modifying any page?
Maybe a normal link like:
https://www.example.com/t/categories/mugs,bags,books
https://www.example.com/products?taxon=1,3,5
I've tried both of them. I get error from the former and get the first category from the latter.
If deface is the only solution, how to do it if I want the link to look like the first link?
If it helps, I use rails 4.2.1 and spree 3.0.1.
I don't think you get this sort of functionality by default in Spree. You're going to have to come up with a custom action that is capable of accepting the multiple categories and returning the products filtered by that category.
You should be able to set this up by through the admin panel in
"Products" --> "Taxonomies"
If you edit "Categories" and add subcategories of "Mugs", "Bags" and "Books" you should be able to get what you are after via
https://www.example.com/t/categories/

can we write javascript code in jsp which is of with struts html tag library

this is phani kumar,
Actually, i am writing one page to show product details. In that i written code to display the
productid list in jsp page with the help of and tags
. but the main problem is, based on the selection of productid, i trying to show the product details(productname, productcost, productstock..like).But i am facing problems to work this.
I am trying it with javascript, but because of struts html taglibrary, i am getting problems here, could u please give me solutions to resolve this problem anyone.
and can anybody tell how to get dropdown selection value into javascript(if we are using tag library in struts)
How are you using javascript to create your view? You should be able to use
<logic:iterate>
to traverse your product collection, then
<bean:write .../>
to display information from each product.
<html:select>
will create a dropdown in your form. Use
<html:option>, <html:options>, or <html:optionsCollection>
to populate each item in the dropdown.

jQuery Mobile option select list with text search?

I have a select option list and im using jQuery Mobile. My list is very long so Id like to give users the option of searching the list by typing in text.
Is there some native / jQuery Mobile way of adding a text search when you focus on the list? If not I guess instead on an input ill need to create a link to a new page with a filter list, and use javascript to populate the 'input' with the value selected.
http://jquerymobile.com/test/docs/lists/lists-search.html
The short answer is no, unless you want to go nuts editing the JQM code to add that feature to the select box. That being said, I also had this problem (with the select menus being way too long), and here's what I did:
For one scenario, I used an autocomplete search box (that had results drop down: http://jqueryui.com/demos/autocomplete/) in addition to the select menu, populated with the data in the select menu. That way the user could choose whether to use the select menu or search.
For a second scenario, I allowed the user to search for something, then brought up a menu (really a dialog plugin) with only the results that matched what they searched for.
Hope this helps.
Personally, I could not get the jqueryui autocomplete to work well with jQuery Mobile. But this autocomplete code from Andy Matthews worked well:
http://www.andymatthews.net/code/autocomplete/
Used in conjection with an input text field, it provides a way for users to type in a few characters and see a list of choices to select.

paginaton dropdown with jquery

I want to have a dropdown that will have the user select which record number they want to be on? so if I ave 200 records in db, it will have 4 pages and dropdown will look like this
"Just an idea..not an exact code"
<select>
<option>1-50</option>
<option>51-100</option>
<option>101-150</option>
<option>151-200</option>
</select>
I seen pagination with other types in jquery but not dropdown. Any help will be appreciated.
Thanks
Check this excellent tutorial/plugin for doing pagination with jQuery. You can bind the change event of your dropdown and then use next, previous callbacks on it.

Resources