source: Dev/branches/rest-dojo-ui/client/pages/sessions/sessions.js @ 256

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

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 1.4 KB
Line 
1$(function(){
2   
3    var errorDisplay = $("#page_sessions_errors");
4   
5   
6    rft.api.getObjects("Session")
7    .done(function(sessions){
8        var sessionList = $("#page_sessions_list");
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    $("#page_sessions_btn_new").click(function(){
18        var name = $("#page_sessions_txt_name").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    $("#page_sessions_btn_edit").click(function(){
34        var uid = $("#page_sessions_list 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    $("#page_sessions_btn_delete").click(function(){
45        var uid = $("#page_sessions_list 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.