Passing an object when navigating in Durandal -


i'm using durandal 2.0. have search view , want pass selected item detail view. know how pass id, since search in case has whole object, i"d pass object when navigating. thought use route splat, i'm not sure how send when activate route.

the route mapped as:

router.map([     { route: '', title: 'search', moduleid: 'viewmodels/search', nav: true },     { route: 'create', title: 'add', moduleid: 'viewmodels/create', nav: true },     { route: 'details*movie', title: 'details', moduleid: 'viewmodels/details', nav: false },     { route: 'edit', title: 'edit', moduleid: 'viewmodels/edit', nav: false } ]).buildnavigationmodel();     

the search view model navigates this:

    var openmovie = function (data) {     router.navigate('details*'+ ??what do here??); }; 

and detail view model has activate function:

    var activate = function(data) {     ???what data be???     return true; }; 

what trying not possible using navigation of router. when navigate, router internally changes url composition lifecycle triggered. in order make work need add object in url query string, pretty ugly..

take @ very completed answer jonathan curtis in durandaljs google groups on how aproach scenario.

the 3 approaches suggested are:

  • parent-child
  • eventaggregator
  • shared context (or model)

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -