所以我有这样的骨干网应用程序,我使用的后端codeigniter。出于某种原因, pushState的:真正的不起作用
So I have this Backbone App where I use Codeigniter for the Backend. For some reason, pushState:true does not work.
所以,我的我的骨干应用程序的main.js有这样:
So, my main.js of my backbone app has this:
Backbone.history.start({ pushState: true, root: App.ROOT });我app.js有这样:
My app.js has this:
var App = { ROOT: '/projects/mdk/' };和我的导航模块,这使得menulinks,每个项目都有这样的:
and my navigation module, which renders the menulinks, each item has this:
this.insertView(new ItemView({ model: new Navigation.ItemModel({ href: App.ROOT + 'home', class: 'home', triggers: 'home', route: this.route }) }));和型号为它:
Navigation.ItemModel = Backbone.Model.extend({ defaults: { href: '', text: '', triggers: [], route: '' } });所有我从这个得到的是找不到网页...
All I get from this is "Page not found"...
添加:当我在它的视图切换到的href:#新闻 - 它的工作原理,但它并不真正有意义。 ..
Add: When I in the view change it to href:'#news' - it works, but it dont really makes sense...
任何人谁知道这里的问题?
Anyone who knows the issue here?
推荐答案好,我找到了一个解决方案通过自己:
ok I found a solution by myself:
我做了这个技巧:
$(document).on('click', 'a:not([data-bypass])', function (evt) { var href = $(this).attr('href'); if (href && href.indexOf('#') === 0) { evt.preventDefault(); Backbone.history.navigate(href, true); } });然后我做了:
href: '#home',这解决了这个问题,现在evereythings运行流畅。
That solved the problem, now evereythings runs fluently..
更多推荐
BackboneJS + codeigniter pushState的真不工作
发布评论