All data retrieval operation should be handled in activate
. You might have to chain multiple calls if they are depended or use $.when
to make multiple calls in parallel. In Durandal 1.2. make sure to return either true, false or a promise from activate to let Durandal know when it's allowed to continue composing.
Best practice for viewAttached
would be to use the passed in view
to limit the jQuery selector otherwise you might accidentally effect elements outside the view. e.g.
viewAttached: function (view) {
$('.date').datepicker().on('show', function (ev) ...
would become
viewAttached: function (view) {
$('.date', view).datepicker().on('show', function (ev) ...
or
viewAttached: function (view) {
$(view).find('.date').datepicker().on('show', function (ev) ...