页面之间传递数据在使用Backbone.js的一个SPA [英] Passing data between pages In a SPA using backbone.js

查看:382
本文介绍了页面之间传递数据在使用Backbone.js的一个SPA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请原谅我,如果这个问题听起来很模糊。我已经找遍了整个网络,我可以就如何做到这一点任何的例子不是 - 这增加的事实,我真的很新的Web开发,这使我有点现货:)

Please forgive me if this question sounds very vague. I have looked all over the web and I can’t any examples on how to do this – this added with the fact I am really new to web development put me in a bit of a spot :)

我所希望做的是有画廊对象的集合(从本地JSON文件加载),显示从每个第一图像作为一个单独的页面上的网格。
当用户点击图像,厨房的详细信息页面加载和显示完成画廊加上标题等。

What I am looking to do is have a collection of "gallery" objects (loaded from a local json file) that displays the first image from each as a grid on a single page. When the user clicks an Image, a "galley details" page is loaded and shows the complete gallery plus the title etc.

我的问题是,你如何去过客所选项目到下一个页面,以便可以将数据注入装起来。

My question is, how do you go about "passing" the selected item to the next page so the data can be injected and loaded up.

我一直在寻找到与创建骨干两种或敲除一个水疗中心,但现在只是一些作品和具有可扩展性将是一个很好的开始。

I have been looking into creating a SPA with either backbone or knockout, but right now just something that works and is scalable would be a great start.

由于数据源是相当小的,我不是在寻找做任何服务器端的东西。只是客户端JS / HTML / CSS。

As the data source is quite small, I’m not looking at doing any server side stuff. Just client side JS/HTML/CSS.

克里斯

推荐答案

也许最简单的是使用localStorage的。我强烈建议使用像 store.js 库做到这一点:

Perhaps the easiest would be to use localStorage. I'd strongly recommend using a library like store.js to do this:

// before you leave the page
store.set("selected", selectedItem);

// on the new page
var selected = store.get("selected");
if (selected == null)
    selected = defaultValue;

这篇关于页面之间传递数据在使用Backbone.js的一个SPA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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