Question

I use Durandal 2.0 & Breeze in my SPA.

I have a sidebar menu for my drivers (Chauffeurs) where user can click on submenus (Récents, Disponibles, Indisponibles) for calling my view with different parameters. This will fill a koGrid with data. The data is fetched in the activate call and the binding of the koGrid is done in the compositionComplete.

enter image description here

Everything goes well most of the time. Things goes wrong when I click very quickly on submenus (calling the same view). Example: I click on 'Récents' and immediately (without waiting for the view to display) I click on 'Disponibles'.

I have the following for the activate:

var activate = function (filterParam) {
    filter(filterParam);
    pagedDataSource.getDataFunction = getData;
    pagedDataSource.getPredicatesFunction = getPredicates;
    return pagedDataSource.reload();
};

And I have the following code for the compositionComplete:

var compositionComplete = function (view) {
    bindEventToList(view, '.kgCellText', gotoDetails);
    $('#mySearchGrid').attr('data-bind', 'koGrid: gridOptions');
    ko.applyBindings(vm, document.getElementById('mySearchGrid'));
};

When I trace the activity, I noted that if user click quickly on submenus, the activate does not have the time to finish and is called again (for the second click of the user) and the compositionComplete does not execute. Then after that, nothing more happened visually. It seems blocked.

Any idea how can I prevent this problem?

Thanks.

Était-ce utile?

La solution

The migration to the latest Durandal version 2.0.1 fixed the problem.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top