小编jes*_*lor的帖子

使用JSON获取Backbone.js集合

我正在使用Backbone.js和Phil Sturgeon的CI休息服务器(绝对值得推荐的AMAZING TOOL).

这是我的页面:http://interr0bang.net/7357/fetch/.它非常基础,模型(Event),集合(Events)和视图(EventView).该集合位于http://api.interr0bang.net/calendar/events,并返回已使用jsonformatter.curiousconcept.com验证的JSON数组.

这是代码:

$(function(){
    var Event = Backbone.Model.extend();
    var Events = Backbone.Collection.extend({
        model: Event,
        url: 'http://api.interr0bang.net/calendar/events',

    });
    var EventView = Backbone.View.extend({
        initialize: function(){
            _.bindAll(this, "render","count");
            this.collection = new Events();
            this.collection.bind("change",this.count);
            this.collection.fetch();
            this.counter = this.collection.length;
            this.render();
        },
        render: function(){
            this.el.html(this.counter);
        },
        count: function(){
            this.counter = this.collection.length;
        }
    });
    eventView = new EventView({el:$('#collection')});
});
Run Code Online (Sandbox Code Playgroud)

视图呈现正常,但它始终显示0,Firebug显示GET请求,状态为200 OK,但响应正文为空...为什么这不起作用?

json backbone.js

7
推荐指数
1
解决办法
2万
查看次数

vanilla/codeigniter登录与jsconnect/SSO的集成

有没有人有使用这个插件的经验?我已经获得了php的客户端库,并在我的控制器中设置了相应的功能.当我从香草的插件设置页面点击"测试"时,我得到一个有效的回复,但现在我被卡住了......我从哪里开始?

为了更清楚这个问题,我不知道我的下一步是什么.我的意思是,我知道我必须遗漏一些东西......继承人我正在使用的控制器功能(或页面)作为插件的端点:

// 1. Get your client ID and secret here. 
$clientID = "1234";
$secret = "1234";

// 2. Grab the current user from your session management system or database here.
//so i check to see if the user is logged in to my codeigniter's auth
//all works fine

// 3. Fill in the user information in a way that Vanilla can understand.
$user = array();

if ($signedIn) {
// i then set these according to the user info of …
Run Code Online (Sandbox Code Playgroud)

codeigniter single-sign-on codeigniter-2

6
推荐指数
1
解决办法
2538
查看次数