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 253 forks source link

Redactor Rails renders multiple forms #151

Open tbcooney opened 9 years ago

tbcooney commented 9 years ago

screen shot 2015-08-17 at 3 40 20 pm screen shot 2015-08-17 at 3 37 52 pm

Creating or updating a post renders multiple forms at first, but if you refresh the view the problem is fixed.

jaymiejones86 commented 9 years ago

I have also experienced this issue.

tbcooney commented 9 years ago

@jaymiejones86 Oh geesus, I spent 45 minutes trying to fix it earlier after following these steps for install, and got no where:

  1. Add 'redactor-rails' gem to Gemfile
  2. bundle install
  3. Include in application.js & application.css.scss
  4. = f.input :content, :input_html => { :class => "redactor" }

Again, the editor works and the view is fixed on refresh but it is still an error. Ended up tagging this as an Issue and wonder if there is a fix or a text editor that won't do this.

jaymiejones86 commented 9 years ago

@tbcooney we had similar issues, only 2 instances of the editor though and the 2 instances showed pretty much all the time.

jaymiejones86 commented 9 years ago

I would also note there was no issue back with 0.4.2

tbcooney commented 9 years ago

@jaymiejones86 I just reverted to 0.4.2 and I get only 2 instances of the editor, however, the extra instance will disappear on refresh, weird. When I reverted to 0.3.7 the issue was no longer present (not the best fix lol).

jaymiejones86 commented 9 years ago

@tbcooney hmmm so odd. Ill need to find some spare time to look and maybe issue a PR, but hope someone else beats me to it.

lucasklaassen commented 9 years ago

Had the same issue and messed around with how the JavaScript was initalizing the editor. It worked fine in development but when deployed it would render two editors in production. I'll look back on my commit notes and try to find the fix for you guys.

brunnogomes commented 9 years ago

Hi guys, I'm also having the same issue. It renders 2 instances of the editor, however even refreshing does not help.

I already revised the initialization code but not luck.

Anyone got any progress on this?

/cc @lucasklaassen @jaymiejones86 @tbcooney

jaymiejones86 commented 9 years ago

@brunnogomes we found that you did not have to have initialisation code if you just want the defaults and are hooking into a class redactor.

If you do some initialisation, make sure the class name is not redactor.

levelingup commented 8 years ago

This happened to me too... I realized that I added a class: "redactor" and initialized it in my javascript code. So if you're going to initialize it, use a different class.

brunnogomes commented 8 years ago

Thanks @jaymiejones86!

jaymiejones86 commented 8 years ago

No worries Brunno. On Fri, 18 Dec 2015 at 5:30 AM, Brunno Gomes notifications@github.com wrote:

Thanks @jaymiejones86 https://github.com/jaymiejones86!

— Reply to this email directly or view it on GitHub https://github.com/SammyLin/redactor-rails/issues/151#issuecomment-165539993 .

Jaymie Jones @pixelstackcom http://jaymiejonesphoto.com http://codercatchup.com https://devbase.io

sankalpsingha commented 8 years ago

Thanks for this info. I was really confused what the issue was. So I just changed the class name from .redactor to .redactor-row in the config.js and called that class in the text areas. Done! :dancer:

jaymiejones86 commented 8 years ago

No worries @sankalpsingha Happy redactoring.

bigos commented 8 years ago

Perhaps it's not exactly the right solution, but I have a quick fix in my fork. https://github.com/bigos/redactor-rails I have modified gem to use all the plug-ins and get rid of duplicate forms.

Gemfile: gem 'redactor-rails', github: 'bigos/redactor-rails', branch: 'master'

application.js //= require redactor-rails //= require redactor-rails/plugins

application.css = require redactor-rails = redactor-rails/plugins

bigos commented 8 years ago

Link to the diff https://github.com/bigos/redactor-rails/commit/ac2cc62c740c616e48b1b02dd4bac943ca2354f6