1

I was following Lazy Blogger for getting started with routing in knockoutJS using crossroads and hasher and it worked correctly.
Now I needed to refresh the content using ajax for Home and Settings page every time they are clicked. So I googled but could not find some useful resources. Only these two links

  1. Stack Overflow Here I could not understand where to place the ignoreState property and tried these. But could not make it work.

        define(["jquery", "knockout", "crossroads", "hasher"], function ($, ko, crossroads, hasher) {
    
        return new Router({
            routes:
            [
                { url: '', params: { page: 'product' } },
                { url: 'log', params: { page: 'log' } }
            ]
        });
    
        function Router(config) {
            var currentRoute = this.currentRoute = ko.observable({});
    
            ko.utils.arrayForEach(config.routes, function (route) {
                crossroads.addRoute(route.url, function (requestParams) {
                    currentRoute(ko.utils.extend(requestParams, route.params));
                });
            });
            activateCrossroads();
        }
    
        function activateCrossroads() {
            function parseHash(newHash, oldHash) {
                //crossroads.ignoreState = true; First try
                crossroads.parse(newHash);
            }
            crossroads.normalizeFn = crossroads.NORM_AS_OBJECT;
    
            hasher.initialized.add(parseHash);
            hasher.changed.add(parseHash);
            hasher.init();
    
            $('a').on('click', function (e) {
                crossroads.ignoreState = true; //Second try
            });
    
        }
    });
    
  2. Crossroads Official Page Here too I could not find where this property need to be set.

If you know then please point me to some url where I can get more details about this.

Community
  • 1
  • 1
Sandeep Kumar
  • 1,505
  • 1
  • 15
  • 24
  • There are two video courses on knockout from John Papa - http://www.johnpapa.net/2forfree/ ( not free anymore though). check it out. he talk about routing in details. – vittore Aug 04 '15 at 14:52
  • @vittore thanks for sharing the video course. Do you know any free resource so that can help me out? – Sandeep Kumar Aug 04 '15 at 15:32
  • How about a video from Knockout's creator? [https://vimeo.com/97519516](https://vimeo.com/97519516) – 300 baud Aug 04 '15 at 20:09

0 Answers0