Canjs: trigger a route event for the current page

423 Views Asked by At

I have a can.Control that looks like this:

can.Control({
    "route": function(){
        ...
    },

    "a.test click": function(){
        can.route.attr({
            page: "home",
            type: "test"
        });
    }
});

"route" callback is not being called if the current page is {page: "home", type: "test"}.

How can I trigger a route event regardless of the page I'm currently on?

My thoughts...
I can call this.route() directly, but then I have to handle changing the URL, which makes it not a good solution.

1

There are 1 best solutions below

0
On
"{can.route} change": function(ev, attr, how, newVal, oldVal) {
    if(how=='your-page') {
        // your change
    }
}

Here about route in canjs: http://canjs.com/docs/can.route.html