From f0821c85800be8c98c465491c131a65392af050c Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 5 Sep 2016 23:57:25 +0200 Subject: Add roots --- public/js/moderators.js | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'public') diff --git a/public/js/moderators.js b/public/js/moderators.js index 1a61075..10dd2a0 100644 --- a/public/js/moderators.js +++ b/public/js/moderators.js @@ -63,7 +63,6 @@ $(document).ready(function(){ }); $('form#suggest').submit(function(){ - var data = $(this).serialize(); var form = $(this); form.clearAlerts(); @@ -71,7 +70,7 @@ $(document).ready(function(){ $.ajax({ url: app_url + 'verb/suggest', method: 'post', - data: data, + data: form.serialize(), error: function(jqxhr, stat, error) { form.addAlert('danger', stat); }, @@ -91,4 +90,29 @@ $(document).ready(function(){ return false; }); + + $('form#add-root').submit(function(){ + var form = $(this); + + form.clearAlerts(); + + $.ajax({ + url: app_url + 'root/create', + method: 'post', + data: form.serialize(), + error: function(jqxhr, stat, error) { + form.addAlert('danger', stat); + }, + success: function(data) { + if (!data.success) { + form.addAlert('danger', data.message); + return; + } + + window.location = window.location; + } + }); + + return false; + }); }); -- cgit v1.2.3