日历不检索本地存储数据

时间:2014-02-17 19:07:51

标签: php jquery json jquery-mobile

尝试使用localstorage设置支持离线视图的活动日历(基于http://www.vissit.com/projects/eventCalendar/的日历)

我已设法将所有数据存储在我的本地存储中,如下所示,但在尝试离线加载日历时,无法加载。有任何想法吗?我需要尽快完成这个: - )

JSON

$.getJSON("dates.json.php", function(data) {
                 calendar_items = data;
                 localStorage.setItem("calendar_items", JSON.stringify(calendar_items));

which stores...

[{"date":"2014-02-04 00:00:00","type":"event","title":"Test","url":"","id":"361"},{"date":"2014-02-05 00:00:00","type":"event","title":"Test 2","url":"","id":"361"},{"date":"2014-02-06 00:00:00","type":"event","title":"Test 3","url":"","id":"361"}]

日历(在线)

$("#eventCalendarHumanDate").html();
$("#eventCalendarHumanDate").eventCalendar({
    eventsjson: "dates.json.php",
    jsonDateFormat: 'human'
});

日历(离线)

$("#eventCalendarHumanDate").html();
$("#eventCalendarHumanDate").eventCalendar({
    eventsjson: localStorage.getItem("calendar_items"),
    jsonDateFormat: 'human'
});

不确定从哪里开始。我试过以下

(JSON.parse(localStorage.getItem(“calendar_items”)))但这也没有用。

0 个答案:

没有答案