Search code examples
ember.jsember-dataember-cli

Page full refresh on link-to


everyone. I've got a strange behaviour after update Ember from 2.9.1 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.9.1 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' });
});

controllers/list.js

import Ember from 'ember';

export default Ember.Controller.extend({
  queryParams: ['page', 'sortBy', 'direction', 'archived'],
  page: 1,
  perPage: 50,
  sortBy: 'createdAt',
  direction: 'asc',
  archived: false
});

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

{{#link-to "list" list.id (query-params page=1 archived=false)}}<i class="icon-list-unordered"></i> {{list.name}} <span class="text-muted text-thin">{{#if activeLeadsCount}}({{activeLeadsCount}}){{/if}}</span>{{/link-to}}

Thanks for any help.


Solution

  • Sorry, guys. I found that it was not full refresh. I have application-loading.hbs with loading circle. And it appears only on app boot, but after fix https://github.com/emberjs/ember.js/pull/14545 it appears any time when I refresh list model. Anyway thanks for help!