与木偶路由默认锚点行动 [英] Default anchor action with Marionette Routing

查看:142
本文介绍了与木偶路由默认锚点行动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个是由一系列的步骤,对应于不同的看法每一个步骤,每一个导航栏一个锚标记。

I have a Marionette application that is composed of a series of steps, each step corresponding to a different view, each with an anchor tag in a navigation bar.

<a href="#toolbox">Select Tools</a>
<a href="#payment">Pay</a>

我现在的斗争是找到构建的URL,使 Marionette.AppRouter 可以回应他们的最好方式。每当我使用像的href方案=/工具箱,页面只是尝试导航离开该URL(绕过路由器),除非我prevent默认锚的作用。我应该使用像片段方案HREF =#工具箱?或者,我应该设置我的 Backbone.history.start()调用不同?什么是这里的最佳实践?

My current struggle is finding the best way to structure the URLs so that the Marionette.AppRouter can respond to them. Whenever I use a scheme like href="/toolbox", the page just tries to navigate away to that URL (bypassing the router), unless I prevent the default action of the anchor. Should I be using a fragment scheme like href="#toolbox"? Or, should I be setting up my Backbone.history.start() call differently? What is the best practice here?

推荐答案

我要做的就是用#toolbox作为的href ,但我还是叫 preventDefault 上的click事件。

What I do is use "#toolbox" as the href, but I still call preventDefault on the click event.

这样的话:


  • 应用程序处理导航,并简单地更新了网址片段

  • 用户可以打开一个新窗口中的链接(或加载书签)预期的页面和土地(因为路由得到的路由控制器触发)

基本上,一旦路径已经被加载,并且用户是内部的木偶的应用程序,路由不应继续触发。相反,控制器动作应通过事件UDPATE应用程序的显示被调用。更多关于这种方法在这里的路由(见实现路径):的http:/ /samples.leanpub.com/marionette-gentle-introduction-sample.pdf

Essentially, once a route has been loaded and the user is "inside" your Marionette app, routes shouldn't be triggered anymore. Instead controller actions should be called via events to udpate the app's display. More on this approach to routing here (see section "Implementing Routing"): http://samples.leanpub.com/marionette-gentle-introduction-sample.pdf

这篇关于与木偶路由默认锚点行动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆