主干js混乱
我听说过很多有关backbone.js 的内容,坦白说我不理解它的概念。是否要求所有元素都应位于单个页面中才能发挥其动画和效果?或者它可以从服务器获取项目并通过转换加载它,或者我的意思是不同的页面,但看起来像单个页面。我不太理解它的概念,所以这就是我问的原因。我正在寻找的是结合主干或任何其他 javascript 框架来与 Rails 项目一起工作,这可以在页面之间提供一些轻松的转换,并且可以提供本机应用程序的外观。
I have heard a lot about backbone.js and quite frankly I don't understand its concept. Does it require that all the elements should be in single page to work out with its animations and effects ? Or it can grab items from server and load it with transition or i mean different pages but make look like a single page. I didn't understand its concept well, so that's why i am asking. What i am looking for is to combine backbone or any other javascript framework to work with a rails project, that could give some ease transition across pages and can give native application look.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Backbone 还通过 MVC 为您提供结构,并且它允许以非常简单的方式与服务器进行通信。您将能够在服务器上更新/获取/保存您的数据(例如您的 Rails 模型)。因此,如果您希望用户在 Ajax 页面上工作而无需重新加载页面,则需要它。
例如,当页面加载时,您将从服务器获取所有数据,然后您将可以访问模型的所有属性,并且能够修改它并将其保存到服务器。
此外,如果您希望模型带有过渡效果,因为 Backbone 是 MVC,您将能够轻松实现这一点。由于您必须选择视图在 DOM 上显示的时间和位置,因此您可以在那时进行转换。
顺便说一句,Backbone 与 Rails 配合得非常好!
Backbone is also here to give you structure by being MVC, and it allows to communicate in a really simple way with the server. You'll be able to update / fetch / save your data (your rails models for example) on the server. So you'll need it if you want your user to work on an Ajax page without having to reload the page.
For example, you'll fetch all your data from the server when the page loads and then you'll have access to all attributes of your models and will be able to modify it and save it to the server.
Moreover, if you want your models to appear with transition, as Backbone is MVC, you'll be able to make that easily. As you have to choose when and where your views will appear on the DOM, you'll be able to put transition at that time.
By the way, Backbone works really great with Rails!
Backbone.js 是关于以某种方式从用户处使用的数据,将其视为浏览器上的 ActiveRecord 加上 Sinatra(或 Rails),事实上,该框架将为您提供一种在浏览器中处理数据的方法,而不是服务器。
如果您正在寻找一种简单的方法来向现有应用程序/网站添加过渡,您可以使用 jquery 插件,例如 Pagify (它依赖于 $.getHtml())修改它以获取子页面的片段,例如我的(有缺陷的)分叉。
Backbone.js is all about data to be used in some way from your users, think about it as ActiveRecord plus Sinatra (or rails) on a browser, infact, the framework will give you a way to handle your data inside a browser instead of the server.
If you are looking for a simple way to add transitions to your existing app/website you could use a jquery plugin like Pagify (it rely on $.getHtml()) modifying it to get a fragment of the subpages like my (buggy) fork.