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.parentNode).slideToggle();
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
$(new_element).appendTo(projectlist).hide().slideDown();
31
var data = serializeForm($(this));
33
ajax_call(callback, $(this).attr("action"), "", data, 'POST');
38
function add_projectset(){
40
$("#add_projectset").attr('disabled', 'disabled');
42
function callback(xhr) {
43
var response = JSON.parse(xhr.responseText);
44
$('#projectset_list').append(response.html);
45
$('#projectset_' + response.projectset_id).hide();
46
$('#projectset_' + response.projectset_id).slideDown();
47
$("#add_projectset").removeAttr('disabled');
48
$(".add-project-link").click(show_add);
51
var data = serializeForm($("#new_projectset_form"));
53
data['ivle.op'] = 'add_projectset';
55
ajax_call(callback, $("#new_projectset_form").attr("action"), "", data,
62
$(this).next().slideToggle();