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/46-edit.js | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 web/js/labitrack.d/46-edit.js (limited to 'web/js/labitrack.d/46-edit.js') diff --git a/web/js/labitrack.d/46-edit.js b/web/js/labitrack.d/46-edit.js new file mode 100644 index 0000000..c7039b0 --- /dev/null +++ b/web/js/labitrack.d/46-edit.js @@ -0,0 +1,44 @@ +(function(){ + function on_submit(label, o) + { + o.save(undef, {success: function() { + label.set_data(o.toJSON()); + Backbone.history.navigate('/view/'+o.id, true); + }}); + } + + function success(o) + { + var data = o.toJSON(); + λ.setcontent('edit', { + id: o.id, + save_text: 'Save', + data: data, + tags: λ.tags + }); + + λ.labelform({ + model: o, + submit: on_submit + }); + } + + var view = λ.routableview.extend({ + render: function (id) { + var o = λ.o.get(id, { + success: function(){ + success(o); + }, + error: function(ev){ + λ.setcontent('notfound', { + action: 'Edit', + id: id, + status: ev.status + }); + } + }); + } + }); + + view.route('edit/:id', 'edit'); +}()); -- cgit v1.2.1