source: Dev/branches/jQueryUI/pages/sessions/sessions.js @ 247

Last change on this file since 247 was 247, checked in by hendrikvanantwerpen, 13 years ago

Introduced basic checking of login.
Added object query and create functions to API.
Fixed sessions overview page.
Added browser history mgmt.

File size: 1.4 KB
RevLine 
[247]1$(function(){
2   
3    var errorDisplay = $("#errorDisplay");
4   
5   
6    rft.api.getObjects("Session")
7    .done(function(sessions){
8        var sessionList = $("#sessions #sessionList");
9        $.each(sessions,function(idx,session){
10            var el = $("<option>");
11            el.val(session.uid);
12            el.text(session.title);
13            sessionList.append(el);
14        });
15    })
16
17    $("#sessions #createSession").click(function(){
18        var name = $("#sessions #sessionName").val();
19        if ( !name ) {
20            errorDisplay.text("Name cannot be empty");
21            return;
22        }
23        rft.api.createObject("Session",{
24            title:name
25        })
26        .done(function(uid){
27            rft.content.goTo("session",{
28                uid:uid
29            });
30        });
31    });
32   
33    $("#sessions #editSession").click(function(){
34        var uid = $("#sessions #sessionList option:selected").val();
35        if ( !uid ) {
36            errorDisplay.text("No session selected in list");
37            return;
38        }
39        rft.content.goTo("session",{
40            uid:uid
41        });
42    });
43   
44    $("#sessions #deleteSession").click(function(){
45        var uid = $("#sessions #sessionList option:selected").val();
46        if ( !uid ) {
47            errorDisplay.text("No session selected in list");
48            return;
49        }
50        rft.api.deleteObject("Session",uid);
51    });
52   
53})
Note: See TracBrowser for help on using the repository browser.