lundi 4 janvier 2016

How to save the endpoint data in model store if call is made from actions in controller

I have created a dialog box using the ember-modal-dialog.The content that is going to displayed in the dialog is received from the server.I am able to make the call to server and fetch the data.But I don't know how to save the data into my model store from actions.

Controller.js

actions:{
    fiModal1: function(photo){
        Ember.$('body').addClass('centered-modal-showing');
        var currentState = this;
        photo.toggleProperty('fidialogShowing'))
            console.log('opendialog');
            raw({
                url: 'http://ift.tt/1Z1vuXE'+photo.get('like_pk')+'/likes/',
                type: 'GET',
            }).then(function(result){
                  currentState.set('model.feed.liker',result)
            });
    },
    bookmarked:function(liker){
       liker.set('is_bookmarked',true)
    },


}

feed.hbs

<p {{action "fiModal" photo }}>{{photo.0.numlikes}}</p>
   {{#if photo.fidialogShowing}}
   {{#modal-dialog translucentOverlay=true close = (action "fiDialogClose" photo)}}

{{#each model.feed.liker as |liker}}
<div class = "col-sm-6">
   {{#if liker.is_bookmarked}}
        <a href {{action "unbookmarked" liker}}>
        <img class="foll" src = "images/button-bookmark-secondary-state-dark-b-g.png"></a>
   {{else}}
        <a href {{action "bookmarked" liker}}>
        <img class="foll" src = "images/button-bookmark.png"></a>
                      {{/if}}
</div>
{{/each}}

Now the problem is that when action inside the dialog box is fired it throws an error:

fiver.set is not function

I think that the problem is occurring because I am not saving the result in the model store.How should I do it.So the action inside the dialog box also works.




Aucun commentaire:

Enregistrer un commentaire