(function(context,$) { context.JK = context.JK || {}; context.JK.SessionScreen = function(app) { function afterShow(data) { var sessionId = data.id; $.ajax({ type: "GET", url: "/api/sessions/" + sessionId }).done(renderSession); } function renderSession(sessionData) { $contents = $('#session-contents'); $contents.empty(); var template = $('#template-session-contents').html(); var contents = JK.fillTemplate(template, sessionData); $contents.html(contents); } function deleteSession(evt) { var sessionId = $(this).attr("action-id"); if (sessionId) { $.ajax({ type: "DELETE", url: "/api/sessions/" + sessionId }).done( function() { self.location="#/home"; } ); } } function events() { $('#session-contents').on("click", '[action="delete"]', deleteSession); } events(); screenBindings = { 'afterShow': afterShow }; app.bindScreen('session', screenBindings); }; })(window,jQuery);