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(){
21
$(this).slideToggle('fast');
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
projectlist.children(".list_empty_indicator").remove()
28
add_section = projectlist.children(".add-project");
29
$(add_section).before(new_element).hide().slideDown();
32
var data = serializeForm($(this));
34
ajax_call(callback, $(this).attr("action"), "", data, 'POST');
39
function add_projectset(){
41
$("#add_projectset").attr('disabled', 'disabled');
43
function callback(xhr) {
44
var response = JSON.parse(xhr.responseText);
45
$('#projectset_list').append(response.html);
46
$('#projectset_' + response.projectset_id).hide();
47
$('#projectset_' + response.projectset_id).slideDown();
48
$("#add_projectset").removeAttr('disabled');
49
$(".add-project-link").click(show_add);
52
var data = serializeForm($("#new_projectset_form"));
54
data['ivle.op'] = 'add_projectset';
56
ajax_call(callback, $("#new_projectset_form").attr("action"), "", data,
63
$(this).next().slideToggle();