1
$(document).ready(function(){
2
$("#new_projectset_form").submit(add_projectset);
3
$(".new_project").submit(add_project);
5
$('.add-project-link').click(show_add);
8
function serializeForm(form){
10
mylist = form.serializeArray();
12
for (var i = 0; i < mylist.length; i++){
13
data[mylist[i].name] = mylist[i].value;
19
function add_project(){
23
function callback(xhr) {
24
var response = JSON.parse(xhr.responseText);
25
var projectlist = $('#projectslist_' + response.projectset_id);
26
var new_element = response.html.split('\n').slice(1).join('\n');
27
if (projectlist.hasClass("emptylist")){
28
projectlist.children().slideUp();
29
projectlist.removeClass("emptylist");
31
$(new_element).appendTo(projectlist).hide().slideDown();
34
var data = serializeForm($(this));
36
ajax_call(callback, $(this).attr("action"), "", data, 'POST');
41
function add_projectset(){
43
$("#add_projectset").attr('disabled', 'disabled');
45
function callback(xhr) {
46
var response = JSON.parse(xhr.responseText);
47
$('#projectset_list').append(response.html);
48
$('#projectset_' + response.projectset_id).hide();
49
$('#projectset_' + response.projectset_id).slideDown();
50
$("#add_projectset").removeAttr('disabled');
53
var data = serializeForm($("#new_projectset_form"));
55
data['ivle.op'] = 'add_projectset';
57
ajax_call(callback, $("#new_projectset_form").attr("action"), "", data,
64
$(this).next().slideToggle();