GithubHelp home page GithubHelp logo

Comments (3)

michelegera avatar michelegera commented on August 12, 2024 1

Aren't these files supposed to be autoloaded by the Administrate::Field::SimpleMarkdown::Engine declaration?

      class Engine < ::Rails::Engine
        Administrate::Engine.add_javascript 'administrate-field-simple_markdown/application'
        Administrate::Engine.add_stylesheet 'administrate-field-simple_markdown/application'
      end

You’re correct, for some reason the skeleton application I was testing this on required those two lines as well.

But I found what the issue is, it's because my model is namespaced (Course::Translation coming from Globalize) and SimpleMarkdown is looking for a textarea with ID course/translation_about instead of course_translation_about.
By changing f.object.class.name.underscore to f.object.class.name.parameterize.underscore in views/fields/simple_markdown/_form.html.erb, the issue seems fixed (Course::Translation.name.parameterize.underscore --> "course_translation").

Ah, good catch! Makes sense, and thanks for opening a PR. I’ll check it out in a minute and release a new version of the gem with your fix.

from administrate-field-simple_markdown.

michelegera avatar michelegera commented on August 12, 2024

Hey @sedubois, thanks for the feedback!

I just scaffolded a project with the same dependencies as the ones you listed, and everything is working fine for me.

Please make sure that you are including both Administrate’s and the plugin assets in your app/assets/config/manifest.js file, like this:

//= link administrate/application.css
//= link administrate/application.js
//= link administrate-field-simple_markdown/application.css
//= link administrate-field-simple_markdown/application.js

Let me know if this fixes it for you.

from administrate-field-simple_markdown.

sedubois avatar sedubois commented on August 12, 2024

Thanks @michelegera, aren't these files supposed to be autoloaded by the Administrate::Field::SimpleMarkdown::Engine declaration?

      class Engine < ::Rails::Engine
        Administrate::Engine.add_javascript 'administrate-field-simple_markdown/application'
        Administrate::Engine.add_stylesheet 'administrate-field-simple_markdown/application'
      end

Also I don't yet have app/assets/config/manifest.js because I'm still running on sprockets 3.7.2.

And anyway I checked the source code and simplemde.min.js and simplemde.min.css are correctly referenced.

But I found what the issue is, it's because my model is namespaced (Course::Translation coming from Globalize) and SimpleMarkdown is looking for a textarea with ID course/translation_about instead of course_translation_about.

Here was the generated code:

  $(function() {
    new SimpleMDE({
      element: document.getElementById('course/translation_about')
    });
  });

By changing f.object.class.name.underscore to f.object.class.name.parameterize.underscore in views/fields/simple_markdown/_form.html.erb, the issue seems fixed (Course::Translation.name.parameterize.underscore --> "course_translation").

from administrate-field-simple_markdown.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.