posted by pboling  10/29/2008

MarkItUp! is a cool textile editor. It is fairly easy to integrate with Rails, but it relies on jQuery, so you must make the jQuery function calls and the Prototype function calls play nice with each other.                                                                                      

At the bottom of the jQuery file add:

/* Set jQuery to run in no-conflict mode */
var J = jQuery.noConflict();

Then if you initialize your MarkItUp! editor like this:


  def markitup_editor_initialize
    "<script type=\"text/javascript\" >
      $(document).ready(function() {
        $(\".markItUpTA\").markItUp(mySettings);
      });
    </script>" 
  end

Just convert the ’$’ to ‘J’, or whatever you named your no conflict mode jQuery in the first step:


  def markitup_editor_initialize
    "<script type=\"text/javascript\" >
      J(document).ready(function() {
        J(\".markItUpTA\").markItUp(mySettings);
      });
    </script>" 
  end

And you are done. You can use this trick for any sweet jQuery tools you have running around your Rails app!

Leave a Comment