Search code examples
ruby-on-railsrubyruby-on-rails-4froala

Rails - Froala editor plugins aren't loading when I first load the page, how do I load the plugins before initializing the editor?


I have froala editor installed on my rails 4.2 app. I'm not using the gem because I have added extra custom buttons to the toolbar. I have all the froala files in /public/froala (know its not best practice but its still easy to update this way and its the only way I could get the custom buttons to work).

I have set the toolbar defaults like so

jQuery ->
          $('#edit').froalaEditor({
            toolbarButtons: ['fullscreen', 'bold', 'italic', 'underline', 'strikeThrough', 'subscript', 'superscript', 'fontFamily', 'fontSize', '|', 'color', 'emoticons', 'inlineStyle', 'paragraphStyle', '|', 'paragraphFormat', 'align', 'formatOL', 'formatUL', 'outdent', 'indent', '-', 'insertLink', 'insertImage', 'insertVideo', 'insertTable', '|', 'quote', 'insertHR', 'undo', 'redo', 'clearFormatting', 'selectAll', 'html'],
            imageResizeWithPercent: true,
            imageDefaultWidth: 70,
            imageInsertButtons: ['imageByURL']

But I have one problem. The toolbar doesnt have the right buttons displayed when I load the page, only after I refresh the page once does the buttons I set display. I asked their support and showed them a video and they told me I don't have the plugins loaded when I first load the page. They said to make sure I load the plugins before initializing the editor.

How can I get that done?


Solution

  • For anyone else that has the same problem its trubolinks that is causing it. I disabled turbolinks and the problem was solved.