1.使用rails的plugin。
* 在http://rubyforge.org/frs/?group_id=2038下载插件的的最高版本。
* 把插件解压缩,并且把以前的名字fckeditor_plugin-0.4.2改成fckeditor。把这个文件包放到你的rails项目的vender/plugin目录下边。
* 在你的plugin目录中运行命令行:rake fckeditor:install进行安装和设定。如果安装成功会发现在public下边有一个upload的目录。
* 使用方法:在你的页面里边引入 <%= javascript_include_tag :fckeditor %>也可以在layout当中引入。
(1)非AJAX方式:非常简单,首先你需要从你的action传来一个对象,如果没有你就会一直收到一个nil错误。假设为@artical=Artical.new,artical有一个content字段用来存储文章内容
然后在页面调用:
<%= fckeditor_textarea("artical", "content", :toolbarSet => 'Simple', :width => '100%', :height => '200px' )%>
如此一来,@artical.content将显示在fckeditor的编辑框内,我们这里为空.
注意,简单的实践是在新建一个models,然后在前一任务里边只声明一个变量content,运行完迁移任务后在controller里边设置一个方法.比如show,这个方法里边只需要有一条语句就可以了 @ artical = Artical.new
*
(2)AJAX方式调用:
<%= form_remote_tag :url => @options.merge(:controller => @scaffold_controller),
:before => fckeditor_before_js('note', 'text') %>
<%= fckeditor_textarea( "artical", "content", :ajax => true ) %>
<%= end_form_tag %>
关于工具条具体某个工具怎么显示,提供那些功能,可以在public/javascripts/fckeditor/fckconfig.js文件里面定义
* 在http://rubyforge.org/frs/?group_id=2038下载插件的的最高版本。
* 把插件解压缩,并且把以前的名字fckeditor_plugin-0.4.2改成fckeditor。把这个文件包放到你的rails项目的vender/plugin目录下边。
* 在你的plugin目录中运行命令行:rake fckeditor:install进行安装和设定。如果安装成功会发现在public下边有一个upload的目录。
* 使用方法:在你的页面里边引入 <%= javascript_include_tag :fckeditor %>也可以在layout当中引入。
(1)非AJAX方式:非常简单,首先你需要从你的action传来一个对象,如果没有你就会一直收到一个nil错误。假设为@artical=Artical.new,artical有一个content字段用来存储文章内容
然后在页面调用:
<%= fckeditor_textarea("artical", "content", :toolbarSet => 'Simple', :width => '100%', :height => '200px' )%>
如此一来,@artical.content将显示在fckeditor的编辑框内,我们这里为空.
注意,简单的实践是在新建一个models,然后在前一任务里边只声明一个变量content,运行完迁移任务后在controller里边设置一个方法.比如show,这个方法里边只需要有一条语句就可以了 @ artical = Artical.new
*
(2)AJAX方式调用:
<%= form_remote_tag :url => @options.merge(:controller => @scaffold_controller),
:before => fckeditor_before_js('note', 'text') %>
<%= fckeditor_textarea( "artical", "content", :ajax => true ) %>
<%= end_form_tag %>
关于工具条具体某个工具怎么显示,提供那些功能,可以在public/javascripts/fckeditor/fckconfig.js文件里面定义