How to dispatch event from common js file to method of component ? #1199
Unanswered
sergeynilov
asked this question in
1. Help
Replies: 1 comment 6 replies
-
Try using your custom event, make sure the event bubbles to the window, and update this: @custom-show-datepicker.window="customShowDatepicker($event.detail)" |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
in my Laravel 8 / tailwindcss 2 / Alpinejs 2.8 app
I added datepicker from https://jsfiddle.net/alr3id/8pLh9cze/ fiddle.
As in some cases I need more 1 datepicker on the form I modified showDatepickerClick
function with name parameter. Also I want to have 1 functions showDatepickerClick, isToday...
defined in common js file and I failed to dispatch method from common.js and catch it in my blade.php file.
I have in test2.blade.php :
where in @custom-show-datepicker I try to catch event in method customShowDatepicker
and in common.js :
To dispatch event from showDatepickerClick I tried 2 ways:
parentRef.$dispatch is not a function
error
in showDatepickerClick above I uncommented line :
Beta Was this translation helpful? Give feedback.
All reactions