当前位置: 动力学知识库 > 问答 > 编程问答 >

backbone.js - relative url not workin in backbone

问题描述:

the problem im having is when is when i click on a link or button on the site which has a relative url i get a 404 error because it sets the link to the root

ex

i have my router setup like:

define([

'jquery',

'underscore',

'backbone',

'views/home/main',

'views/projects/list',

'views/users/list'

], function($, _, Backbone, mainHomeView, projectListView, userListView ){

var AppRouter = Backbone.Router.extend({

routes: {

'projects': 'showProjects',

'users': 'showUsers',

'*actions': 'defaultAction'

},

initialize: function(){

this.home = new mainHomeView.homeView(this);

this.user = new userListView.userView(this);

this.project = new projectListView.projectView(this);

},

showProjects: function(){

this.project.render();

},

showUsers: function(){

this.user.render();

},

defaultAction: function(actions){

this.home.render()

}

});

var initialize = function(){

var app_router = new AppRouter;

Backbone.history.start();

};

return {

initialize: initialize

};

});

and my buttons/links are set like :

 <ul>

<li><a href="#/links">Links</a></li>

</ul>

so if my url is: www.some-web-site.com/example/ex1/

and i click the link it should set the url to:

www.some-web-site.com/example/ex1/#/links

instead i get: 404 not found - www.some-web-site.com/links

am i missing something? thanks

分享给朋友:
您可能感兴趣的文章:
随机阅读: