Made working principle more error prone and allowed for error recovery using JS/JSON

This commit is contained in:
Christian Wolf 2019-06-18 16:57:46 +02:00
parent a30e5d76a1
commit 7f019dd740
3 changed files with 13 additions and 4 deletions

View File

@ -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';
}
}

View File

@ -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();
});
});

View File

@ -14,7 +14,7 @@ $user = $auth->getCurrentUser();
if($mode === 'edit')
{
echo "<form method='POST' action='index.php?option=com_clubs&task=parts.edit&format=json'>";
echo "<form method='POST' action='index.php?option=com_clubs&task=parts.edit&format=json' class='clubs-part'>";
switch($type)
{