form_for 内的 text_field_with_auto_complete [英] text_field_with_auto_complete inside form_for

查看:40
本文介绍了form_for 内的 text_field_with_auto_complete的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个简单的问题 - 我如何在 form_for 块中使用 text_field_with_auto_complete ?

Simple question really - how do I use text_field_with_auto_complete inside a form_for block?

我试过做 f.text_field_with_auto_complete 但这会产生错误,仅使用 text_field_with_auto_complete 本身似乎没有任何作用.

I've tried doing f.text_field_with_auto_complete but that gives an error, and just using text_field_with_auto_complete by itself doesn't seem to do anything.

我在这里遗漏了什么吗?

Am I missing something here?

推荐答案

几个月前我编写了一个插件,允许您直接在 fields_for<上调用text_field_with_auto_complete"方法/code> 或 form_for.这个想法是通过生成唯一的 id 来支持在表单中出现多次的文本字段以允许 javascript 工作,但它也可能有助于解决您的问题,或者至少给您一些新的想法.

A couple of months back I wrote a plugin that allows you to call the "text_field_with_auto_complete" method directly on fields_for or form_for. The idea was to support text fields that appear more than once in a form by generating unique ids to allow the javascript to work, but it might help solve your problem also, or at least give you some new ideas.

参见:http://github.com/pat11639/repeated_auto_complete

...这篇文章详细了解它的工作原理:http://patshaughnessy.net/2008/10/31/modifying-the-autocomplete-plugin-to-allow-repeated-fields

...and this article for details for how it works: http://patshaughnessy.net/2008/10/31/modifying-the-autocomplete-plugin-to-allow-repeated-fields

这篇关于form_for 内的 text_field_with_auto_complete的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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