简体   繁体   English

返回Backbone.js应用程序内部,而无需更改URL

[英]Go back inside a Backbone.js App without URL change

We have a Marionette view, let's call it 'products' there we have a 'submit' button, which shows another view, but, without changing the URL. 我们有一个木偶视图,在这里有一个“提交”按钮,我们称之为“产品”,该按钮显示了另一个视图,但是没有更改URL。 So, the problem is, that inside the 'submit' view, if the user presses the back button, they expect to go to the 'products' view, but instead, they are taken back to the 'home' view, because we didn't change the URL when showing 'submit'. 因此,问题在于,在“提交”视图中,如果用户按下“后退”按钮,他们希望进入“产品”视图,但是相反,它们却被带回到“主页”视图,因为我们没有显示“提交”时,请勿更改URL。

So how can we push a state in history without changing the URL? 那么,如何在不更改URL的情况下推送历史状态?

See Backbone.js routing without changing url . 请参阅Backbone.js路由而不更改url

An idea - ripped from the answer but changed the name of the function so it doesn't override the current navigate : 一个想法-从答案中删除,但更改了函数的名称,因此它不会覆盖当前的navigate

Router = Backbone.Router.extend({

  navigateQuietly: function (url) {

    // Override pushstate and load url directly
    Backbone.history.loadUrl(url);

  }

});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM