spohlenz / tinymce-rails

Integration of TinyMCE with the Rails asset pipeline
Other
814 stars 257 forks source link

Edit not always showing #145

Open lperry65 opened 10 years ago

lperry65 commented 10 years ago

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 ?

spohlenz commented 10 years ago

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.

lperry65 commented 10 years ago

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.

echarp commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

After some testing, I recommand using this event instead

$(document).on 'page:receive', ->
  tinymce.remove()
spohlenz commented 10 years ago

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

sunchess commented 9 years ago

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

leonardk1 commented 9 years ago

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

hvillero commented 8 years ago

Thank you that worked:

 $(document).on 'page:receive', ->
  tinymce.remove()" 
dlegr250 commented 8 years ago

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

caiotarifa commented 7 years ago

Only for reference... For Turbolinks 5:

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

@caiotarifa not click... bug

brnpimentel commented 7 years ago
document.addEventListener('turbolinks:load', function() {
        tinymce.remove();
        tinymce.init(config);
});

just works.

ohyoungjooung2 commented 6 years ago

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

dlegr250 commented 6 years ago

@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.

ohyoungjooung2 commented 6 years ago

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.