lundi 29 octobre 2018

Ember 3, DataTable render buttons with actions

I'm migrating my app from Ember 1 to 3. It is using DataTables plugin for $JQuery with custom render method to show buttons dispatching controller's actions.

Now, my problem is that the older version of Ember allowed me to do kind of this (myController.js):

var dataTablesColumns = [
  .
  .
  .
  {
    mRender: function(data, type, row) {
      return `<button onclick="getView($(this)).parentController.send('myAction')`
    }
  }
]

Since Ember 3 does not support views anymore this approach is not working. How can I call controller's myAction using the dataTables in this way?

I've tried:

onclick="this.parentController.send('myAction')"
onclick="this.send('myAction')"

But nothing works. this refers to the button in the context not to the controller.

Thank you for any suggestion or help!




Aucun commentaire:

Enregistrer un commentaire