lundi 23 janvier 2017

Append a link-to from a post response in Ember

I have a JSON response from an external server that generates a grid of responses. The route they go to is setup in Ember, but I can't figure out how to use the link-to helper in appending the results, causing the application to reload when clicking.

export default Ember.Component.extend({
  actions: {
    switchGenre(genre){
      $.post('http://ift.tt/2kk7z7w',{'genre':genre},function (data) {
        $('#stations').empty()
        var activeRow = 0;
        $('#stations').append('<div class="row" id="row'+activeRow+'">')
        $.each(data,function(index,station){
          if(index%4==0 && index > 0){
            activeRow++;
            $('#stations').append('<div class="row" id="row'+activeRow+'">')
          }
          $('#row'+activeRow).append('<a href="/station/'+station.id+'"></a>')

        })
      })
    }

  }
});




Aucun commentaire:

Enregistrer un commentaire