BackboneJS + codeigniter pushState的真不工作

编程入门 行业动态 更新时间:2024-10-20 09:31:07
本文介绍了BackboneJS + codeigniter pushState的真不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

所以我有这样的骨干网应用程序,我使用的后端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的真不工作

本文发布于:2023-11-01 18:13:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550050.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:真不   工作   BackboneJS   codeigniter   pushState

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!