lundi 11 juillet 2016

Send action from ajax response with ember

I'm new to ember & I try to send action to some route in my app,
But I want to send the action from AJAX response because I also need the inserted id from the server
So I try to do:

$.ajax({
    method: "POST",
    url: "in",
    data: datajson,
    success: function (result) {
        data.id = result.id;
        self.sendAction('action', data);
    }
});

self is a global variable that I assign to it the value of this of the component.

Now its not working, nothing sent to the router
But when I put the sendAction out of the ajax success function
The function in the "father" route is trigerred

So what I can do?
(I use Ember 1.10)

Aucun commentaire:

Enregistrer un commentaire