轨道 3 中的观察字段 [英] Observe_field in rails 3

查看:54
本文介绍了轨道 3 中的观察字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个下拉菜单.当下拉列表中的值发生变化时,我需要添加一个文本框.我在 rails 2.3.5 中使用obseve_field"标签完成了这项工作.现在我正在使用 rails 3.那么我如何在 rails 3 中编写它.

I had a dropdown. I need to add a textbox when the value changes in the dropdown. I had done this using "obseve_field" tag in rails 2.3.5. Now I am moving into rails 3. So how I write it in rails 3.

推荐答案

如果您想在 Rails 3 中使用遗留的 Prototype 助手(如 observe_field),请查看 prototype_legacy_helper 的 GitHub 存储库.

If you want to use the legacy Prototype helpers (like observe_field) in Rails 3, check out the GitHub repository for prototype_legacy_helper.

否则,您可以使用新的 UJS 自己编写此 JavaScript.请参阅旧 observe_field 方法的这两块代码:

Otherwise, you can write this JavaScript yourself using the new UJS. See these two blocks of code for the old observe_field method:

并参见 http://http://www.simonecarletti.com/blog/2010/06/unobtrusive-javascript-in-rails-3/的第 2 部分www.simonecarletti.com/blog/2010/06/unobtrusive-javascript-in-rails-3/ 了解如何在 jQuery 中执行此操作.

and see Part 2 at http://www.simonecarletti.com/blog/2010/06/unobtrusive-javascript-in-rails-3/ to see how to do this in jQuery.

这篇关于轨道 3 中的观察字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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