tinymce-rails icon indicating copy to clipboard operation
tinymce-rails copied to clipboard

Edit not always showing

Open lperry65 opened this issue 10 years ago • 17 comments

Im using tinymce-rails 4.1.0 with rails rails 4.1.4

I've followed the setup instruction and the first time I go to the page the editor shows, however if I navigate away and the back I just see a textarea. If I refresh the browser the editor shows again ?

lperry65 avatar Jul 06 '14 10:07 lperry65

Are you using turbolinks? This sounds like it could be related to that. I'll need to look into what is required for full compatibility with turbolinks.

spohlenz avatar Jul 06 '14 23:07 spohlenz

Hi Pohlenz, thanks for getting back to me. Yes and I can confirm that the problem goes away if I disable turbolinks. I'm also using jquery.turbolinks by kossnocorp.

Thanks,

Lee.

lperry65 avatar Jul 08 '14 07:07 lperry65

I'm also having this issue, it seems some dev are just disablink turbolinks for the incriminating pages.

Instead, I'm sure there is some call to do, maybe to clean up the DOM, will have to search :-)

echarp avatar Jul 16 '14 22:07 echarp

The following could have been a solution, but it didn't work for me: http://blog.gbinghan.com/2012/04/reintialize-tinymce-after-jquery-load.html

echarp avatar Jul 16 '14 22:07 echarp

Solution trouvée \o/ (solution found).

You just need to delete existing editors before init new one. The command I use in my "ready" handler:

$(document).ready ->
  tinymce.remove()

echarp avatar Jul 17 '14 13:07 echarp

After some testing, I recommand using this event instead

$(document).on 'page:receive', ->
  tinymce.remove()

echarp avatar Jul 17 '14 13:07 echarp

Thanks @echarp. I will add some info to the readme, or if possible, see if I can make it work seamlessly.

spohlenz avatar Jul 18 '14 00:07 spohlenz

Thanks @echarp. I had some error. But it is "ReferenceError: Can't find variable: safari" js error only safari, in chrome it works.

sunchess avatar Oct 04 '14 08:10 sunchess

Thanks @echarp this helps tinymce.remove() but I will also try out second option

leonardk1 avatar May 25 '15 13:05 leonardk1

Thank you that worked:

 $(document).on 'page:receive', ->
  tinymce.remove()" 

hvillero avatar Feb 16 '16 16:02 hvillero

Also confirming that this works:

$(document).on "page:receive", ->
  tinymce.remove()

$(document).on "ready page:load", ->
  tinymce.init({ selector: "selector" })

I'm using TinyMCE via the CDN and not the tinymce-rails gem, but this solution solved my issue with TurboLinks.

Rails 4.2, TinyMCE 4

dlegr250 avatar Jun 17 '16 17:06 dlegr250

Only for reference... For Turbolinks 5:

$(document).on('turbolinks:request-end', function() {
  if (tinyMCE) { tinyMCE.remove(); }
});

caiotarifa avatar Sep 27 '16 00:09 caiotarifa

@caiotarifa not click... bug

nikolaokonesh avatar Oct 10 '16 15:10 nikolaokonesh

document.addEventListener('turbolinks:load', function() {
        tinymce.remove();
        tinymce.init(config);
});

just works.

brnpimentel avatar Apr 20 '17 22:04 brnpimentel

But, I do not know where to put this script? Anybody help me?

ohyoungjooung2 avatar May 02 '18 18:05 ohyoungjooung2

@ohyoungjooung2 You can put that JavaScript code in any JS file that is included in your Rails application.

By default, Rails has an app/assets/javascripts/application.js file which is a manifest file, meaning it essentially is an index or listing of other loaded JS files. This is done in order to combine all your JS files into a single file, which is more efficient to send across the web rather than having 30+ smaller files (overhead of requests is big compared to transferring data).

I would personally put the snippet into a file at app/assets/javascripts/global.js and then in your app/assets/javascripts/application.js file add a line for //= require global.

The //= require ... is relative to the current folder your file is in.

dlegr250 avatar May 02 '18 20:05 dlegr250

dlegr250. Thanks for your kindness. I created Nginx+Unicorn+Mysql+rails 4.2.10. With turbolink no data setting, it was fine on development mode, but with nginx..blabla setting with docker run image, it is not successful. Sometimes it is ok when I click Edit, but sometimes NOT OK.

Well,,,it is not working yet.

ohyoungjooung2 avatar May 02 '18 21:05 ohyoungjooung2