Adding jQuery to posts


(Alain Leon) #1

I am learning how to use the plugin system. Starting with a very basic test plugin that just adds a border via jQuery to all images in a post. Here’s my initializer file in the plugin, it’s not actually adding the borders, though:

plugins/test/assets/javascripts/initializers/make-border.js.es6

import { decorateCooked } from 'discourse/lib/plugin-api';

export default {
  name: "make-border",
  initialize: function(container) {
    decorateCooked(container, function($elem) {
      $('img', $elem).css('border', "solid 2px red");
    });
  }
};

(Alain Leon) #2

I’m not sure what fixed it but it seems like it’s working now. Maybe restarting rails server or renaming things fixed it.