0

What is wrong in the code? expected results: when the page loads like url/case#!open-cases or url/cases#!new then the target route listner('new route' or ':filter-cases route') should be called but it doesn't happen

PageControl = can.Control({
        init : function(el, options) {
            debugger;
        },
        'new route': function() {debugger;},
        ':filter-cases route': function() {debugger;
            new CaseList('#content');
        },
        'route': function(data) {debugger;
            new CaseList('#content');
        }
    });

    $(document).ready(function() {
        //initDialog();
        can.route(':filter-cases');
        can.route('case/:id');
        can.route('new');
        //can.route('', {filter: 'open' })
        can.route.ready();

        new PageControl(window);
    });
4

1 回答 1

1

如果您在初始化页面控件can.route.ready() 后调用它应该可以工作:

$(document).ready(function() {
    //initDialog();
    can.route(':filter-cases');
    can.route('case/:id');
    can.route('new');
    //can.route('', {filter: 'open' })

    new PageControl(window);
    can.route.ready();
});
于 2014-06-08T16:25:18.033 回答