刷新页面时如何重新加载 Spine.js 视图?

发布于 2024-12-29 17:21:51 字数 372 浏览 1 评论 0原文

例如,我遵循 Spine 文档中的 Spine+Rails 教程。它是一个基本的 Rails 应用程序,列出了 CRUD 的帖子,但使用 Spine.js,所以它都是异步的并且超级快。这一切都很棒。

但是,刷新页面或手动点击 http://spiny.dev/#/posts/5/edit 这样的 URL 只会加载 #/posts' 内容,但会保留网址。它看起来像...

...当它实际上应该显示编辑视图时。

如何将 Spine.js 设置为“恢复”到应有的位置?

For example, I followed the Spine+Rails tutorial in Spine's docs. It is a basic Rails app that lists Posts to CRUD, but with Spine.js, so it's all async and super fast. That's all great.

However, refreshing the page or manually hitting in a url like http://spiny.dev/#/posts/5/edit only loads #/posts' content but keeps the url. It looks like...

this
.

... when it should in fact display an editing view.

How can one set up Spine.js to 'resume' to where it should?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

错爱 2025-01-05 17:21:51

检查你的控制台(cmd+shift+i,然后控制台选项卡,或者当弹出对话框时,按左下角的 >= 图标)(这是你编写 javascript 时最好的新朋友)。

您可能会遇到类似“未知记录”的错误。问题是您必须提前获取模型。在所有子控制器初始化之前。至少这是我的猜测。

另外,要避开脚手架的东西。它给了你太多的聪明才智和概念,而这些对你来说早年并没有什么好处。只需从一些基本内容开始,然后根据需要进行重构,这样您最终就会了解当前脚手架代码中的每一部分代码的作用。

Check your console (cmd+shift+i and then the console tab, or when the dialog pops up press the >= looking icon in the bottom left corner) (this is your new best friend when writing javascript).

You probably have an error that gets thrown like 'Unknown record'. The problem is that you have to fetch your models earlier. Before all the subcontrollers are initialized. At least that's my guess.

Also, shy away from the scaffolding stuff. It gives you too much cleverness and concepts that aren't good for you so early on. Just begin with something basic and refactor as needed so you end up knowing what every bit of code does in the current scaffold code you have.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文