26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/autosuggest/form_helper.rb', line 26
def autosuggest_field_tag(name, value, source, options={})
text_field_class = "autosuggest_#{name}"
options[:class] = "#{options[:class].to_s} #{text_field_class}"
autosuggest_options = options.delete(:autosuggest_options) || {}
autosuggest_options.reverse_merge!("queryParam" => "query", "selectedItemProp" => "name", "searchObjProps" => "name", "neverSubmit" => "true", "asHtmlName" => "#{name}")
_out = text_field_tag(name, value, options)
_out << raw(%{
<script type="text/javascript">
$(document).ready(function(){
$('.#{text_field_class}').autoSuggest('#{source}', #{autosuggest_options.to_json});
});
</script>
})
_out
end
|