在轨道中使用observe_field而不是onkeydown的原因是什么?

时间:2021-07-17 11:50:31

Is there any good reason why most rails developers use observe_field when they want trigger specific action when text input box is changed, rather then using onkeydown? I would expect, that in most of the cases using observe_field results much more code generated than just using native hook onkeydown.

大多数rails开发人员在更改文本输入框时想要触发特定操作时使用observe_field,而不是使用onkeydown是否有任何理由?我希望,在大多数情况下,使用observe_field会产生比仅使用本机钩子onkeydown更多的代码。

1 个解决方案

#1


0  

I think it's just a convenient way rails supplied for the person who doesn't know about javascript, or who doesn't want to write another piece of JavaScript code.

我认为这只是为不了解javascript的人提供的一种方便的方式,或者谁不想编写另一段JavaScript代码。

#1


0  

I think it's just a convenient way rails supplied for the person who doesn't know about javascript, or who doesn't want to write another piece of JavaScript code.

我认为这只是为不了解javascript的人提供的一种方便的方式,或者谁不想编写另一段JavaScript代码。