Triggering Actions from Connector from Plugin


#1

Hello guys,
I am writing a small plugin.
The server functionality is in place, I can access it via API without problems.

Now I also have a connector in place using an outlet - this is rendering fine.

The problem I have now is, that I want to trigger an actin from a button in the template file. Where would I need to place the corresponding action?

Tried different things, like extending the Routes like so:

export default Discourse.Route.extend({
  actions: {
    myAction: function() {
      console.log("Do something");
    }
  }
});

Maybe someone could point me in the right direction.

Greetz,
Chris


(cpradio) #2

The outlet you are using will ultimately help drive what component/model you need to reopen and add an action to.

This plugin is no longer needed, but I’m keeping it around as an example, because it took me a while to figure it out too.

In short, you want to setup an initializer that reopens the compoent you want to extend with a new action.


#3

Thank you, this was the missing link.

The outlet I am using does not have a matching component, so I looked one level higher and just reopened and extended an available controller.

Since actions bubble up, I could also reopen the matching Router and add it there (which I tried, just to make sure that I grasped it ;-)).

You helped my understanding the whole stack a little bit more - Thank you.

Greetz,
Chris