Simple_form 输入作为文本和自动完成 [英] Simple_form input as both text and autocomplete

查看:30
本文介绍了Simple_form 输入作为文本和自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 gem 'simple_form', '2.0' 和 gem 'rails3-jquery-autocomplete', '1.0.10'.

I am using gem 'simple_form', '2.0' and gem 'rails3-jquery-autocomplete', '1.0.10'.

我无法让字符串字段接受两个 ':as' 参数.

I am unable to make a string field accept two ':as' arguments.

<%= f.input :product_description , :url => autocomplete_product_name_products_path,
:as => :text, :as => :autocomplete, :placeholder=>"Type product name",
:input_html => {:class =>"span2", :rows => 6}, wrapper: :inline_label, label:false  %>

如果我删除 :as => :text,自动完成部分有效,但 ':rows => 6' 部分失败.

If I remove :as => :text, the auto-complete part works but ':rows => 6' part fail.

如果我同时保留两者,我会得到 6 行,但自动完成功能停止工作.

And if I keep both, I get 6 rows but the auto-complete stops working.

我需要此字段具有多行以及自动完成功能.这是一个非常愚蠢的问题,但我被卡住了.请帮忙.

I need this field to have have multiple rows as well as auto-complete. This is a really silly question but I am stuck. Please help.

推荐答案

Simple Form 没有定义 autocomplete 输入.但是,如果您需要自动完成输入和文本类型,我认为您可以这样做:

Simple Form doesn't define an autocomplete input. But if you need an autocomplete input and the text type I think you can do:

f.input :product_description ,
:url => autocomplete_product_name_products_path,
:as => :autocomplete,
:placeholder=>"Type product name",
:input_html => {:class =>"span2", :rows => 6, type => :text },
wrapper: :inline_label, label: false

这篇关于Simple_form 输入作为文本和自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆