2013-05-07 14 views
1

我有這樣的URL:

something.com/#page/id(與Backbone.js的結構)

我要檢查,如果該ID存在,並且使用使用它在DOM underscore.js,我知道我可以用window.location.href.split做到這一點,但我只想知道是否有更合適更清潔的方法。網址參數,使用Backbone.js的

回答

1
"page/:id": "someFunction" #this will be your route and it should have a function. 

# In that someFunction you can check parameter (id) as shown below. 

someFunction: function (id) { 
    console.log(id); 
}