router - Durandal routing issue -
i have small spa test app durandal. have wired issue. first, folder structure is:
app
--durandal
--viewmodels
----user.js
--views
----user.html
--main.js
, when structure works fine. if create structure
app
--durandal
--_user
----viewmodels
------user.js
----views
------user.html
i error localhost/app/_users/viewmodels/users.html 404 not found. , happens after user.js loaded require.js.
my main.js looks like
require.config({ paths: { "text": "../durandal/amd/text" } }); define(function (require) { var system = require('../durandal/system'), app = require('../durandal/app'), router = require('../durandal/plugins/router'), viewlocator = require('../durandal/viewlocator'), logger = require('../logger'); system.debug(true); app.start().then(function () { // route use conventions modules // assuming viewmodels/views folder structure router.useconvention(); // when finding module, replace viewmodel string // view find partner view. // [viewmodel]s/sessions --> [view]s/sessions.html // otherwise can pass paths modules, views, partials // defaults viewmodels/views/views. viewlocator.useconvention(); app.setroot('viewmodels/shell'); // override bad route behavior write // console log , show error toast router.handleinvalidroute = function (route, params) { logger.logerror('no route found', route, 'main', true); }; }); });
i assume issue has router.useconvention(); or viewlocator.useconvention(); simple can't find reason kind of behavior.
any help, suggestion, idea how solve this?
thanks
this because of behavior of view locator, defaults looks views/viewmodels in first structure describe.
you can change behavior supplying own view locator function, or calling useconvention()
useconvention(modulespath, viewspath, areaspath)
Comments
Post a Comment