【发布时间】:2014-04-17 16:04:59
【问题描述】:
我正在寻找一种在 CanJS 中从一个 html 页面导航到另一个 html 页面的方法。下面是场景:
index.html 包含一个带有忘记密码链接的登录表单(使用 ejs 构建)。
index.html
<div id="container"></div>
control.js
var loginForm=can.Control({
init:function(element,options)
{
var frag=can.view('login.ejs',this.options);
this.element.html(frag);
},
'#forgotPasswordLink click':function(el,ev)
{
//Wants to pass the control to forgotpassword.html.
//Also wants to pass the flow to forgotpassword controller with some data
}
})
new loginForm('#container',{data:data})
我的要求是当我点击忘记密码链接时,当前页面应该导航到 forgotpassword.html。
一种方法是在 ejs 中填充链接的 href 属性,但这不是一个好习惯,因为当前页面控件将失去其意义。我正在寻找一个优化的解决方案。如果我错了,请纠正我
在网络上,我找到了大部分 CanJS 的单页应用程序示例。如果有人可以将我指向多页应用程序演示/示例,那就太棒了。
提前谢谢:)
【问题讨论】:
-
你不是在做单页应用吗?我的意思是多个视图,但在一个文件中!
-
@CherifBOUCHELAGHEM 不,我想使用多个 html 文件。不想一次又一次地重新加载 div
标签: javascript jquery canjs canjs-routing