From 7f019dd7405d0c13432821346b702121e73e704d Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Tue, 18 Jun 2019 16:57:46 +0200 Subject: [PATCH] Made working principle more error prone and allowed for error recovery using JS/JSON --- src/site/controllers/parts.json.php | 2 +- src/site/js/edit.js | 13 +++++++++++-- src/site/views/mypage/tmpl/parts.php | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/site/controllers/parts.json.php b/src/site/controllers/parts.json.php index 2290583..094c74d 100644 --- a/src/site/controllers/parts.json.php +++ b/src/site/controllers/parts.json.php @@ -53,7 +53,7 @@ class ClubsControllerParts extends BaseController $user->setName($name); $user->save(); - $this->setRedirect('index.php?option=com_clubs&view=mypage&layout=parts&type=name'); + return 'index.php?option=com_clubs&view=mypage&layout=parts&type=name'; } } diff --git a/src/site/js/edit.js b/src/site/js/edit.js index b75eb4c..2069403 100644 --- a/src/site/js/edit.js +++ b/src/site/js/edit.js @@ -21,10 +21,19 @@ jQuery(function($){ ev.preventDefault(); var form = $(this).parent(); $.post(form.attr('action'), form.serializeArray(), function(d){ - form.replaceWith(d); + if(d.success) { + $.get(d.data, function(d2){ + form.replaceWith(d2); + }); + } else { + alert(d.message); + } }); }); - + $(document).on('submit', 'form.clubs-part', function(ev){ + ev.preventDefault(); + $('a.clubs-save', this).click(); + }); }); diff --git a/src/site/views/mypage/tmpl/parts.php b/src/site/views/mypage/tmpl/parts.php index 59cd349..b7db9b9 100644 --- a/src/site/views/mypage/tmpl/parts.php +++ b/src/site/views/mypage/tmpl/parts.php @@ -14,7 +14,7 @@ $user = $auth->getCurrentUser(); if($mode === 'edit') { - echo "
"; + echo ""; switch($type) {