Steve_Ng
(Steve Ng)
March 7, 2016, 7:03am
1
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?
tgxworld
(Alan Tan)
March 7, 2016, 8:24am
2
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 .
4 Likes
joebuhlig
(Joe Buhlig)
March 7, 2016, 3:36pm
3
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.
https://github.com/joebuhlig/discourse-feature-voting/blob/master/assets/javascripts/initializers/feature-voting.js.es6
4 Likes