mardi 3 janvier 2017

Ember JS: Page full refresh on link-to

everyone. I've got a strange behaviour after update Ember from 2.5 to 2.10. After this update, when I navigate List links with link-to helper I've got a full page refresh instead of particle refresh. In Ember 2.5 it was a particle refresh. Maybe I've missed something in these updates.

Here is my code for List

app/router.js

import Ember from 'ember';
import config from './config/environment';

const Router = Ember.Router.extend({
  location: 'auto',
  rootURL: '/app/'
});


Router.map(function() {
    this.route('home', { path: '/' });
    this.route('list', { path: '/list/:listId' }, function() {
        this.route('lead', { path: 'lead/:leadId', resetNamespace: true });
    });
    this.route('pageNotFound', { path: '/page-not-found' });
});

routes/list.js

import Ember from 'ember';
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
import RouteMixin from 'ember-cli-pagination/remote/route-mixin';

export default Ember.Route.extend(AuthenticatedRouteMixin, RouteMixin, {

  queryParams: {
    page: {refreshModel: true},
    perPage: {refreshModel: true},
    sortBy: {refreshModel: true},
    direction: {refreshModel: true},
    archived: {refreshModel: true}
  },

  intercom: Ember.inject.service('intercom'),

  leadLink: 'lead',

  model(params)
  {
    var intercom = this.get('intercom');
    var store = this.get('store');
    var list;

    params.leadLink = this.leadLink;

    if (params.listId) {
      list = this.store.findRecord('list', params.listId).then(function (list) {

        intercom.update({
          "Emails": list.get('user.discovered_emails'),
          "Limit": list.get('user.max_discovered_emails')
        });

        return list;
      });
    }
    else {
      params.title = 'All leads';
    }

    return Ember.RSVP.hash({
      list: list,
      leads: this.store.query('lead', {
        filter: this.getFilter(params)
      }, { reload: true }).then(function (leads) {
        params.total = leads.get('meta.total');
        leads.forEach(function (lead) {
          var list = store.peekRecord('list', lead.get('listId'));
          lead.set('list', list);
          return lead;
        });
        return leads;
      }),
      lists: this.store.peekAll('list'),
      params: params
    });

  },
// ....

templates/components/sidebar-list-item.hbs

<i class="icon-list-unordered"></i>  <span class="text-muted text-thin">()</span>

Thanks for any help.




Aucun commentaire:

Enregistrer un commentaire