Question

I created a project using hottowel 2.0.1 in VS 2012 and have the following code following the HotTowel course/example. However I got following error.

Uncaught TypeError: Object # has no method 'navigateTo' ?

I set a break point at the line and found router doesn't have method navigateTo. However, it does have method navigate. Is the name changed?

define(['services/datacontext', 'plugins/router', 'services/logger'],
function (datacontext, router, logger) {
    ......
    var gotoDetails = function (selectedEvent) {
        if (selectedEvent && selectedEvent.Id()) {
            var url = '#/eventdetail/' + selectedEvent.Id();
            router.navigateTo(url);
        }
    };

    var viewAttached = function (view) {
        bindEventToList(view, '.event-brief', gotoDetails);
    };

    var bindEventToList = function (rootSelector, selector, callback, eventName) {
        var eName = eventName || 'click';
        $(rootSelector).on(eName, selector, function () {
            var event = ko.dataFor(this);
            callback(event);
            return false;
        });
    };
    //#endregion

    var vm = {
        activate: activate,
        deactivate: deactivate,
        refresh: refresh,
        events: events,
        title: title,
        attached: viewAttached
    };

    return vm;

});
Was it helpful?

Solution

You should convert your application to Durandal 2:

http://www.johnpapa.net/upgrading-durandal-to-version-2-0/ (amongst other changes there is this: router.navigateTo is now router.navigate)

or use official Durandal 2 template instead of HotTowel

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top