dimanche 17 décembre 2017

ember refresh/reload model after change data in mirage

I need to refresh/reload my model-hook again after I did changes like add or edit my modal by an action. I have seen a lot of topics like this but either there are deprecated or not working in my case.

This is my component.js-file called "listing.js":

import Component from '@ember/component';

export default Component.extend({
    actions: {
        togglePower: function(a){
            console.log(a);
            var data = new Array();
            data.push(a);
            $.ajax({
                cache:false,
                type: 'POST',
                url: "/api/device",
                data: JSON.stringify(data),
                contentType: "application/json"
                })

                this.get('users.single.households.single.rooms.single.devices.single').send('refresh');
        }
      }
});

Mirage receives my data and is able to work with it. But for now I need to reload my page to see my changes. So I tried to add the last line in the listing.js which is

this.get('users.single.households.single.rooms.single.devices.single').send('refresh');

But this doesn´t work for me. The console comes up with:

TypeError: this.get(...) is undefined

This is my route:

        model(){
...},
        actions: {
            refresh: function() {
                this.refresh();
              }
            }

>     }




Aucun commentaire:

Enregistrer un commentaire