Chapters
44 Chapters
|
4:19:56
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!
Subscribe to download the code!
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Subtitles
Subscribe to download the subtitles!
Subscribe to download the subtitles!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
11.
External DOM Updates
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
This course is also built to work with Vue 3!
What JavaScript libraries does this tutorial use?
// package.json
{
"devDependencies": {
"@fortawesome/fontawesome-free": "^5.15.1", // 5.15.1
"@symfony/webpack-encore": "^0.30.0", // 0.30.2
"axios": "^0.19.2", // 0.19.2
"bootstrap": "^4.4.1", // 4.5.3
"core-js": "^3.0.0", // 3.6.5
"eslint": "^6.7.2", // 6.8.0
"eslint-config-airbnb-base": "^14.0.0", // 14.2.0
"eslint-plugin-import": "^2.19.1", // 2.22.1
"eslint-plugin-vue": "^6.0.1", // 6.2.2
"regenerator-runtime": "^0.13.2", // 0.13.7
"sass": "^1.29.0", // 1.29.0
"sass-loader": "^8.0.0", // 8.0.2
"vue": "^2.6.11", // 2.6.12
"vue-loader": "^15.9.1", // 15.9.4
"vue-template-compiler": "^2.6.11", // 2.6.12
"webpack-notifier": "^1.6.0" // 1.8.0
}
}
3 Comments
Hello @weaverryan,
I have a unique use case. We have huge project that started with symfony 2, bootstrap 3 and a whole lot of jquery to manipulate the dom. We upgraded the symfony version successfully and now we want to upgrade the front-end libraries to bootsrap 5 and latest jquery and basically latest versions of other JS packages. Two of those packages are datetimepicker and chosen (select on steroids) which are now deprecated. For the datetimepicker, we could not find a solution that works with latest technologies and also has a timezone option out of the box which is critical to the project. There are some datetimepickers that do that but they are either vue libraries or react libraries, that is where we started looking at symfony-ux-vue. Sorry for the long background tale but I needed to explain that to get to my questions:
Hopefully I made sense and looking forward to getting a response from you or anyone in the community.
Kind Regards.
Hi there @Phil!
Wow, that's an annoying situation! So first, yes, while it seems like overkill, what you're saying is totally possible. And if you loaded the vue controller stuff lazily, users wouldn't even need to download the Vue JavaScript until they're on a page that renders a Vue component. Now, to your questions!
Exactly how you'd render it depends on how that date picker works. But I'd probably render the Vue component where it needs to live but possibly hidden by default. Then create a Stimulus controller, attach it to the "date input" and, on click, unhide the Vue component (you could even hide the wrapper around the Vue component, then unhide that wrapper). Or perhaps the Datepicker library is a bit more hands on, and handles opening itself. I'm doing some guessing there :).
Either way, there will be some way with the Datepicker component to know when a date is selected. From somewhere inside of Vue, I would probably dispatch a native browser event - https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent - on the
inputelement (or the root date picker element - it doesn't matter much - but make sure the event bubbles up). In a Stimulus controller that is attached to the element (or an ancestor) the event is dispatched on, listen to that event. Then, grab the value and do whatever you need to with jQuery.It's a pretty big thing to bring in JUST for a date picker :/, though I'm not too aware of patches and other problems. I'm sure you're already bummed out that you can't find a decent dater picker. So, yes, I would LOVE to AVOID this situation, but what's the alternative? If you CAN get the old datetimepicker to work... I would definitely try. But if not, yea, you don't want to create one of these things by hand... that'd be even more annoying.
Let me know if any of these ramblings help - I'd love to know what you end up doing.
Cheers!
Thank you @weaverryan, it definitely helps. The old datepicker used bootstrap 3 and is incompatible with bootstrap 5 so that is unfortunately not an option. The vue route seems like the only work-around but it feels patchy and over the top. But we might not have another option at the moment. I will keep you updated on what the final solution will be.
Cheers, Phil!
"Houston: no signs of life"
Start the conversation!