Introducing the jsautocomplete_builder gem
Usage
require 'jsautocomplete_builder'
jab = JsAutocompleteBuilder.new(server: {list: 't205', action: 'hello3'})
#puts jab.to_webpage
File.write '/tmp/autocomplete.html', jab.to_webpage
The above example generates an autocomplete enabled web page. The suggestion list is fetched (using AJAX) from the relative URL at t205 and the search request is actioned using the relative URL hello3.
Here's a sample of what's returned from the AJAX request to t205:
<li tabindex='3' onblur='hideList()' onkeyup="itemKeyup(event.keyCode, this)" onclick='itemSelected(this)'>apple</li> <li tabindex='4' onblur='hideList()' onkeyup="itemKeyup(event.keyCode, this)" onclick='itemSelected(this)'>banana</li> <li tabindex='5' onblur='hideList()' onkeyup="itemKeyup(event.keyCode, this)" onclick='itemSelected(this)'>ghi</li> <li tabindex='6' onblur='hideList()' onkeyup="itemKeyup(event.keyCode, this)" onclick='itemSelected(this)'>jkl</li>
Resources
- jsautocomplete_builder https://rubygems.org/gems/jsautocomplete_builder
jsautocomplete_builder js builder ajax html autocomplete