Skip to content
Advertisement

Tag: alpine.js

How to change shared state in Alpine.js?

I’m trying to hide multiple elements inside the DOM by changing shared state when window is resized. And when i try to It should change the state ** hideOnMobile** to true but it doesn’t somehow any idea? Answer Have you tried using @resize.window? (ie. adding the resize listener using Alpine.js) it should make your code simpler than using window.onresize +

AlpineJs Extract value from select[option]

Trying to use the x-model.number to get values from select option to calculate the values. Using the below input text works. How do I translate it on the select option? Answer I believe it should work by putting the x-model on the select instead of the option. To make the selected state be correct, it’s also probably a good idea

Alpine.js – nested components

I have code like this with nested components: but it seems it does not work. Is there any why to make it work using nested components or maybe Alpine.js cannot handle this yet? OF course I’m aware that changing: into would solve the issue, but this way I would have single component. Answer Alpine.js doesn’t support nesting as of v2.x

Advertisement