v0.9.8 - Fixed participate/stop participating, so that you no longer hard refresh
This commit is contained in:
@@ -57,9 +57,9 @@
|
||||
{!! session()->get('signup#' . $event->id) !!}
|
||||
<div class="row" style="justify-content: space-between; margin-top: 16px;">
|
||||
@if (count(\App\UserEvent::query()->where('event_id', '=', $event->id)->where('user_id', '=', Auth::user()->id)->get()) > 0)
|
||||
<a style="margin: 0; padding: 0; font-weight: 700;" class="sde-blue text-center" href="javascript:void(0);" onclick="ajaxCallCancel({{ $event->id }})" >{{__('msg.afmeld')}}</a>
|
||||
<a style="margin: 0; padding: 0; font-weight: 700;" class="sde-blue text-center" href="javascript:void(0);" onclick="ajaxCall({{ $event->id }}, this)" >{{__('msg.afmeld')}}</a>
|
||||
@else {{-- ^ If you're already participating in the event, then show a ´cancel´ button - v Else show a ´participate´ button --}}
|
||||
<a style="margin: 0; padding: 0; font-weight: 700;" class="sde-blue text-center" href="javascript:void(0);" onclick="ajaxCall({{ $event->id }})" >{{__('msg.tilmeld')}}</a>
|
||||
<a style="margin: 0; padding: 0; font-weight: 700;" class="sde-blue text-center" href="javascript:void(0);" onclick="ajaxCall({{ $event->id }}, this)" >{{__('msg.tilmeld')}}</a>
|
||||
@endif
|
||||
<a style="margin: 0; padding: 0; font-weight: 700;" class="sde-blue text-center" href="{{route("events.show", ["event" => $event->id ])}}">{{__('msg.læsmere')}}</a>
|
||||
<a style="margin: 0; padding: 0; font-weight: 700;" class="sde-blue text-center" href="{{route("events.accountsignups", ["event" => $event->id ])}}">{{__('msg.sedeltagere')}}</a>
|
||||
@@ -84,36 +84,36 @@
|
||||
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
|
||||
}
|
||||
|
||||
function ajaxCall(event_id) {
|
||||
function ajaxCall(event_id, el) {
|
||||
if(el.innerHTML === "{{__("msg.tilmeld")}}") {
|
||||
axios.post("{{ route("userevents.createajax") }}",
|
||||
{
|
||||
event_id: event_id
|
||||
}
|
||||
).then(function (response) {
|
||||
var data = response.data;
|
||||
|
||||
axios.post("{{ route("userevents.createajax") }}",
|
||||
{
|
||||
event_id: event_id
|
||||
}
|
||||
).then(function (response) {
|
||||
var data = response.data;
|
||||
snackbar(data);
|
||||
|
||||
snackbar(data);
|
||||
setTimeout(function(){document.location.reload(false)}, 2000);
|
||||
}).catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
}
|
||||
el.innerHTML = "{{__("msg.afmeld")}}";
|
||||
}).catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
} else if(el.innerHTML === "{{__("msg.afmeld")}}"){
|
||||
axios.post("{{ route("userevents.createajaxcancel") }}",
|
||||
{
|
||||
event_id: event_id
|
||||
}
|
||||
).then(function (response) {
|
||||
var data = response.data;
|
||||
|
||||
function ajaxCallCancel(event_id) {
|
||||
snackbar(data);
|
||||
|
||||
axios.post("{{ route("userevents.createajaxcancel") }}",
|
||||
{
|
||||
event_id: event_id
|
||||
}
|
||||
).then(function (response) {
|
||||
var data = response.data;
|
||||
|
||||
snackbar(data);
|
||||
setTimeout(function(){document.location.reload(false)}, 2000);
|
||||
}).catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
el.innerHTML = "{{__("msg.tilmeld")}}";
|
||||
}).catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user