Skip to content

Instantly share code, notes, and snippets.

@lukaspili
Last active August 29, 2015 13:57
Show Gist options
  • Save lukaspili/9743830 to your computer and use it in GitHub Desktop.
Save lukaspili/9743830 to your computer and use it in GitHub Desktop.
/*global define*/
define([
'underscore',
'backbone',
'models/client'
], function (_, Backbone, ClientModel) {
'use strict';
var ClientCollection = Backbone.Collection.extend({
model: ClientModel,
url : function() {
return APP.BASE_URL + 'prospect/clients';
},
parse: function(json) {
console.log('JSON = ' + json);
}
});
return ClientCollection;
});
/*global define*/
define([
'jquery',
'underscore',
'backbone',
'templates',
'collections/client'
], function ($, _, Backbone, JST, ClientCollection) {
'use strict';
var ClientsView = Backbone.View.extend({
template: JST['app/scripts/templates/clients.ejs'],
el: 'body',
initialize: function() {
_.bindAll(this, "render");
var self = this;
this.clients = new ClientCollection();
this.clients.bind('reset', this.render());
this.clients.fetch({
success: function (collection, response) {
console.log('Success: ' + response);
self.clients = response;
// self.trigger('update', '');
}
})
// this.render();
},
render : function () {
console.log('render');
this.$el.html(this.template({clients: this.clients}));
return this;
}
});
return ClientsView;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment