SammyLin / redactor-rails

This repo is deprecated. Please check out official gem for Redactor 2. https://github.com/Redactor2/redactor2_rails
MIT License
389 stars 254 forks source link

Multiple config.js files #107

Open jeremylynch opened 10 years ago

jeremylynch commented 10 years ago

I want to implement two versions of the Redactor text-editor in my rails app with different config files. How can this be achieved?

jeremylynch commented 10 years ago

I found a temporary solution by determining the controller from the url path all with jquery. Once the controller is determined,

function Getcontroller() {
  var controller = window.location.pathname.split('/')[1];
  return controller
}

$(document).ready(function() {
  controller = Getcontroller()
  if (controller == 'users') {
    config_1()
  } else {
    config_2()
  }
});

function config_1() {
  redactor config_1 here
}

function config_2() {
  redactor config_2 here
}
marslo commented 10 years ago

How can I use two different configs in one Controller? For example, one for post, and another for comment.

asecondwill commented 10 years ago

untested, but could you not have a different class identifying the textarea and two different JS calls to redactor them:

$('.redactor-simple').redactor(
    {    
      buttons: [ 'formatting', 'bold', 'italic', 'unorderedlist','orderedlist','link','underline']
    }
  );

$('.redactor-really-simple').redactor(
    {    
      buttons: [ 'underline']
    }
  );