Overwriting controllers in plugin

Hi, I wanted to add additionally functionality through a plugin.

I added a topic controller at plugins/xx/assets/javascripts/discourse/controllers/topic.js.es6

and I have

import TopicController from 'discourse/controllers/topic';
export default TopicController.reopen({
   actions: {
      own_actions:function() { debugger; };

when I tried to call the action from my topic.hbs template, it says action own_action is not found. is theer anything I would have to do to initialize this controller?

Ideally, you’ll want to reopen the controller inside an initializer.

Have a look at the “initialize code” section under Beginner's Guide to Creating Discourse Plugins - Part 1. :slight_smile:


If you want another example, take a look at the voting plugin. I do something similar there. It’s not from the controller itself but it’s close.