single page application - Durandal 2 upgrade redirect issue -


hello , taking @ issue.

i have been migrating spa application use durandal 2.0 library, following sage advice oft savior, john papa. , have completed upgrade process, find strange behavior (or lack of behavior) when try navigate using menu buttons. isn't happening browser doesn't redirect new page. interesting thing browser address bar populated , if click in address bar , press enter (hard reload), redirected expected.

i've looked around , not caused due security check/redirect have seen other discussing elsewhere. durandal code unmodified.

js on pages can quite trivial:

define([], function () {     console.log("welcome loaded");     var vm = {           title: 'welcome'     };      return vm; }); 

so guess in configuration of durandal.

main.js:

    require.config({     paths: {         'text': '../scripts/text',         'durandal': '../scripts/durandal',         'plugins': '../scripts/durandal/plugins',         'transitions': '../scripts/durandal/transitions',         'knockout': '../scripts/knockout-2.3.0',         'bootstrap': '../scripts/bootstrap',         'jquery': '../scripts/jquery-1.9.1'     },     shim: {         'bootstrap': {             deps: ['jquery'],             exports: 'jquery'         }     } });  define('jquery', function () { return jquery; }); define('knockout', ko);  define(['durandal/system', 'durandal/app', 'durandal/viewlocator'],     function (system, app, viewlocator) {      // enable debug message show in console          system.debug(true);      app.configureplugins({         router: true,         dialog: true,         widget: true     });      app.start().then(function () {         toastr.options.positionclass = 'toast-bottom-right';         toastr.options.backgroundpositionclass = 'toast-bottom-right';          // when finding viewmodel module, replace viewmodel string          // view find partner view.         viewlocator.useconvention();          // adapt touch devices         // app.adapttodevice();         //show app setting root view model our application.         app.setroot('viewmodels/shell', 'entrance');     }); }); 

shell.js:

define(['../../scripts/durandal/plugins/router', 'viewmodels/config', 'services/datacontext'], function (router, config, datacontext) {      function addsession(item) {         router.navigate(item.hash);     }      function boot() {         //    $(".page-splash-message").text("configuring routes...");         router.makerelative({ moduleid: 'viewmodels' });         router.map(config.routes);         router.buildnavigationmodel();         $(".page-splash-message").text("let's make traxx..!");          return router.activate();     }      function failedinitialization(error) {         var msg = 'app initialization failed: ' + error.message;     }      return {         addsession: addsession,         adminroutes: adminroutes,         profileroutes: profileroutes,         visitorroutes: visitorroutes,         router: router,          activate: function () {             datacontext.primeeditdata().then(boot).fail(failedinitialization);         }     }; }); 

routes in config.js

define(['../../scripts/durandal/plugins/router'], function (router) {         toastr.options.timeout = 4000;         toastr.options.positionclass = 'toast-bottom-right';         var startmodule = 'welcome';         var servicename = 'api/zepher';         var imagesettings = {             imagebasepath: '../content/images/photos/',             unknownpersonimagesource: 'unknown_person.jpg'         };      var routes = [         { route: '', moduleid: 'home/welcome', title: 'welcome', nav: false, },         { route: 'welcome', moduleid: 'home/welcome', title: 'welcome', nav: false, },         { route: 'notfound', moduleid: 'home/notfound', title: 'not found', nav: false, },         { route: 'roadmap', moduleid: 'home/roadmap', title: 'roadmap', nav: false, },         { route: 'register', moduleid: 'account/register', title: 'register', nav: true, caption: '<i class="fa fa-user"></i> register' },         { route: 'registeraccounts', moduleid: 'account/registeraccounts', title: 'register accounts', nav: false, caption: '<i class="fa fa-key"></i> register accounts', },      ];         return {         debugenabled: ko.observable(true),         imagesettings: imagesettings,         servicetitle: servicename,         startmodule: startmodule,         router: router,         routes: routes,         activate: function () {             console.log("config activate called");             router.makerelative({moduleid: 'viewmodels'});              router.map(routes);              router.buildnavigationmodel();               //sets conventional mapping              //unrecognized routes              router.mapunknownroutes('home/nontfound', 'not-found');               //activates router              return router.activate();              // no longer needs start module         }     }; }); 

found missing in upgrade, thought i'd share i've learned.

seems forgot update shell.html file.

from this:

<div>     <header>         <!--ko compose: {view: 'shared/nav', aftercompose: router.afterlogging, transition: 'entrance' } --><!--/ko-->     </header>      <section id="content" class="main">          <!--ko compose: {model: router.activeitem, aftercompose: router.aftercompose, transition: 'entrance', cacheviews: true } --><!--/ko-->     </section>     <footer>         <!--ko compose: {view: 'shared/footer'} --><!--/ko-->     </footer> </div> 

to this:

<div>     <header>         <!--ko compose: {view: 'shared/nav', aftercompose: router.afterlogging, transition: 'entrance' } --><!--/ko-->     </header>      <section id="content" class="main container-fluid page-host" data-bind="router: { transition: 'entrance', cacheviews: true }">     </section>     <footer>         <!--ko compose: {view: 'shared/footer'} --><!--/ko-->     </footer> </div> 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -