JavascriptMVC:如何调用控制器的历史方法?
JMVC 有一个历史记录插件,可让您与 URL 的哈希片段进行交互。例如,您可以更改 URL 的 #hash 部分,以使应用程序内的某些操作可添加书签,并允许人们使用浏览器的后退按钮进行导航。
不幸的是,我使用它的运气并不好。
以下代码创建一个 JMVC 控制器,尝试将浏览器 URL 设置为 example.com/myApp#controller/someController
之类的内容。但是,什么也没有发生,因为历史记录插件定义的 redirectTo() 方法未定义。我也尝试过History.redirectTo()。
steal.plugins("jquery/controller/history");
$.Controller.extend('MyControllerWithHistory', {}
{
'.item click': function( el ){
redirectTo({controller:'someController'});
}
});
我做错了什么?
谢谢!
JMVC has a History plugin that lets you interact the URL's hash fragment. For example, you can change the #hash part of the URL to make certain actions inside your app bookmarkable, and allow people to navigate using the browser's back button.
Unfortunately, I'm not having much luck using it.
The following code creates a JMVC controller that tries to set the browser URL to something like example.com/myApp#controller/someController
. However, nothing happens because the redirectTo() method that the History plugin says it defines, is undefined. I've also tried History.redirectTo().
steal.plugins("jquery/controller/history");
$.Controller.extend('MyControllerWithHistory', {}
{
'.item click': function( el ){
redirectTo({controller:'someController'});
}
});
What am I doing wrong?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过
this.redirectTo()
:通过包含历史记录插件,您可以向
$.Controller
添加诸如redirectTo
之类的方法。Have you tried
this.redirectTo()
:By including the history plugin you are adding methods such as
redirectTo
to$.Controller
.