diff --git a/skolehjem/resources/views/app/events/index.blade.php b/skolehjem/resources/views/app/events/index.blade.php
index 4aab9f8..8041a1d 100644
--- a/skolehjem/resources/views/app/events/index.blade.php
+++ b/skolehjem/resources/views/app/events/index.blade.php
@@ -57,9 +57,9 @@
{!! session()->get('signup#' . $event->id) !!}
@if (count(\App\UserEvent::query()->where('event_id', '=', $event->id)->where('user_id', '=', Auth::user()->id)->get()) > 0)
-
{{__('msg.afmeld')}}
+
{{__('msg.afmeld')}}
@else {{-- ^ If you're already participating in the event, then show a ´cancel´ button - v Else show a ´participate´ button --}}
-
{{__('msg.tilmeld')}}
+
{{__('msg.tilmeld')}}
@endif
$event->id ])}}">{{__('msg.læsmere')}}
$event->id ])}}">{{__('msg.sedeltagere')}}
@@ -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);
+ });
+ }
}
@endsection
diff --git a/skolehjem/resources/views/app/events/yourevents.blade.php b/skolehjem/resources/views/app/events/yourevents.blade.php
index bcdd4b5..d2f86d3 100644
--- a/skolehjem/resources/views/app/events/yourevents.blade.php
+++ b/skolehjem/resources/views/app/events/yourevents.blade.php
@@ -58,9 +58,9 @@
{!! \App\Helpers::closetags(substr($userevent->description, 0, 300) )!!}
@if (count(\App\UserEvent::query()->where('event_id', '=', $userevent->id)->where('user_id', '=', Auth::user()->id)->get()) > 0)
-
{{__('msg.afmeld')}}
+
{{__('msg.afmeld')}}
@else {{-- ^ If you're already participating in the event, then show a ´cancel´ button - v Else show a ´participate´ button --}}
-
{{__('msg.tilmeld')}}
+
{{__('msg.tilmeld')}}
@endif
$userevent->id ])}}">{{__('msg.læsmere')}}
$userevent->id ])}}">{{__('msg.sedeltagere')}}
@@ -86,36 +86,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);
+ });
+ }
}
@endsection
diff --git a/skolehjem/resources/views/app/news/index.blade.php b/skolehjem/resources/views/app/news/index.blade.php
index 5c32db3..1a5ef87 100644
--- a/skolehjem/resources/views/app/news/index.blade.php
+++ b/skolehjem/resources/views/app/news/index.blade.php
@@ -52,9 +52,9 @@
@if ($new->type_id == 3) {{-- If it's displaying an event, then show `Tilmeld`, `Læs mere` & `Se deltagere` --}}
@if (count(\App\UserEvent::query()->where('event_id', '=', $new->arrangement_id)->where('user_id', '=', Auth::user()->id)->get()) > 0)
-
{{__('msg.afmeld')}}
+
{{__('msg.afmeld')}}
@else {{-- ^ If you're already participating in the event, then show a ´cancel´ button - v Else show a ´participate´ button --}}
-
{{__('msg.tilmeld')}}
+
{{__('msg.tilmeld')}}
@endif
$new->arrangement_id ])}}">{{__('msg.læsmere')}}
$new->arrangement_id ])}}">{{__('msg.sedeltagere')}}
@@ -83,36 +83,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);
+ });
+ }
}
@endsection