I want to have the hash url like this,

site.com/#/page/edit/about-us/

so I set the router in my backbone,

routes: {
        '/page/edit/:url/':    'renderDynamicPage',
    },

    renderDynamicPage: function (url) {
        console.log(url);
    },

but nothing comes out.

it should be about-us

any ideas why and how I can get around to this?

有帮助吗?

解决方案

Backbone.js documentation says

Note that you'll want to avoid using a leading slash

try

routes: {
        'page/edit/:url':    'renderDynamicPage',
    },

    renderDynamicPage: function (url) {
        console.log(url);
    },
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top