768x90 Getting Online Shouldn't be Tough- $7.49 .com Domains at Go Daddy

HTML Editor or Rich Text Editor for Your Ruby on Rails Apps

1 . Nice Edit

  • Create your text area in your form_tag range

<%= text_field "demo", "tea_poci", "id"=>"myArea2", :rows=>10, :cols=>22%>

.
  • Create additional button for option of using text editor or not.
<%= submit_tag "Add Editor",:type => 'button', "onclick"=>"addArea2();" %>
<%= submit_tag "Remove Editor",:type => 'button',
"onclick"=>"removeArea2();" %>
  • Put this code under submit_tag "Remove Editor" :
<script type="text/javascript" src="http://js.nicedit.com/nicEdit-latest.js">


</script>

<script type="text/javascript">


//<![CDATA[

var area1, area2;

function addArea2() { area2 = new nicEditor({fullPanel : true}).panelInstance('myArea2');}

function removeArea2() { area2.removeInstance('myArea2'); }


bkLib.onDomLoaded(function() { toggleArea1(); });


//]]>


</script>

  • Done !! You can see image below :



2. Textile Editor

  • [~] gem install RedCloth
  • [~] ruby script/plugin install svn://errtheblog.com/svn/plugins/acts_as_textiled
  • [~] script/plugin install http://svn.webtest.wvu.edu/repos/rails/plugins/textile_editor_helper/
  • [~] rake textile_editor_helper:installGo to yor Model / Active Record that is corresponding to your text_area and put :
class MyModel < ActiveRecord
acts_as_textiled :my_text

end

  • Enable your prototype.js.
<%= javascript_include_tag 'prototype' %>
.

  • Here's a short code for your rhtml or html.erb :

<%= textile_editor 'item', 'my_text' -%>
<%= textile_editor_initialize -%>



3. widgEditor

  • Extract the files
  • Copy the widgEditor.js file into your applications public/javascripts folder (you can configure it by changing this file)
  • Copy the widgEditor.css file into your applications public/stylesheets folder.
  • Copy all the images from the widgEditor distribution to your public/images folder.
  • Include the javascript and css files in your layout file.
  • Give any text field you want to be an editor field a class of “widgEditor”.
  • Here's a short code for your view :
<'HEAD'>
<'/HEAD'>
<% form_tag :action => 'what ever' do %>
< %= stylesheet_link_tag 'widgEditor' %>
< %= javascript_include_tag 'widgEditor' %>
< %= text_area 'node', 'content', :cols => "50", :rows=>"3", :class=>"widgEditor" %>
<% end %>
<% end_form_tag %>

No Response to "HTML Editor or Rich Text Editor for Your Ruby on Rails Apps"

 
powered by Blogger