gpt4 book ai didi

ruby-on-rails - text_field_with_auto_complete 内 form_for

转载 作者:数据小太阳 更新时间:2023-10-29 07:23:31 25 4
gpt4 key购买 nike

真的很简单的问题 - 如何在 form_for block 中使用 text_field_with_auto_complete

我试过执行 f.text_field_with_auto_complete 但这会出错,而且仅使用 text_field_with_auto_complete 本身似乎没有任何作用。

我是不是漏掉了什么?

最佳答案

我个人使用这个:

<%= f.text_field :name, :autocomplete => "off" %><div class="auto_complete" id="customer_name_auto_complete"></div>

并手动添加自动生成的 Javascript 和 CSS。这是 Javascript:

new Ajax.Autocompleter('customer_name', 'customer_name_auto_complete', '/customers/auto_complete_for_customer_name', {
method:'get',
paramName:'customer[name]',
minChars: 3
});

这是 CSS:

div.auto_complete {
width: 350px;
background: #fff;
}

div.auto_complete ul {
border:1px solid #888;
margin:0;
padding:0;
width:100%;
list-style-type:none;
}

div.auto_complete ul li {
margin:0;
padding:3px;
}

div.auto_complete ul li.selected {
background-color: #ffb;
}

div.auto_complete ul strong.highlight {
color: #800;
margin:0;
padding:0;
}

关于ruby-on-rails - text_field_with_auto_complete 内 form_for,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/244808/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com