in_place_editing
Posted by ashchan on January 9th, 2008 filed in Rails应用Rails 2中in_place_editing被抽出成为一个单独的插件;而prototype库则升级为1.6.0.1。一些由以前版本升级至2.0版本的Rails应用的in place editing功能,若使用了:script => true选项就会出错,表现为编辑完成后,编辑框内文字显示为一段Javascript代码而非输入的内容。如下面的用法:
1 | <%= in_place_editor_field :recipe, :description, {}, { :script => true, :rows => 6, :cols => 50 } %> |
造成这个错误的原因,是Prototype1.6中去除了evalScripts选项,而这个选项即是由in_place_editor_filed中的:script来指定的。Prototype中加入了一个新的选项htmlResponse,其含义与evalScripts恰好相反。
找到了问题的根源,解决方法便有了,修改vender/plugins/in_place_editing/lib/in_place_macros_helper.rb,将给evalScripts赋值的一行改掉便可:
1 2 | #js_options[’evalScripts’] = options[:script] if options[:script] js_options[’htmlResponse’] = !options[:script] if options[:script] |
参考:
in_place_editing
Prototype
Related posts:
- in_place_editor for rails2.0.2 in_place_editor使用: script/plugin install in_place_editing # Controller class BlogController < ApplicationController...
Related posts brought to you by Yet Another Related Posts Plugin.
Leave a Comment