From 5e54ba7aa27b95d1e0568693915e735ab8058ff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= Date: Thu, 28 Jun 2012 19:49:45 +0000 Subject: Initial version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Asbjørn Sloth Tønnesen --- web/js/labitrack.d/47-recent.js | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 web/js/labitrack.d/47-recent.js (limited to 'web/js/labitrack.d/47-recent.js') diff --git a/web/js/labitrack.d/47-recent.js b/web/js/labitrack.d/47-recent.js new file mode 100644 index 0000000..bb49e1f --- /dev/null +++ b/web/js/labitrack.d/47-recent.js @@ -0,0 +1,54 @@ +(function(){ + function hdl_add(){ + console.log('add'); + } + + function hdl_remove(){ + console.log('remove'); + } + + function hdl_reset(){ + console.log('reset'); + this.render(); + } + + var collection = Backbone.Collection.extend({ + model: λ.o, + url: 'recent.json', + comparator: function(object){ + return -object.get('updated'); + } + }); + + var recent = Backbone.View.extend({ + initialize: function() { + var messages = this.collection; + messages.bind("reset", hdl_reset, this); + messages.bind("add", hdl_add, this); + messages.bind("remove", hdl_remove, this); + }, + render: function(){ + var data = { + rows: this.collection.toJSON() + }; + console.log(data); + $(this.el).html(λ.template('objecttable', data)); + } + }); + + var view = λ.routableview.extend({ + initialize: function() { + λ.routableview.prototype.initialize.call(this); + this.browse = new recent({collection: new collection()}); + }, + render: function (page) { + page || (page = 1); + λ.setcontent('recent'); + this.browse.el = $(this.el).find('#objecttable_ph')[0]; + this.browse.render(); + this.browse.collection.fetch(); + } + }); + + view.route('recent'); +}()); -- cgit v1.2.1