-
-
Notifications
You must be signed in to change notification settings - Fork 356
[LiveComponent] Smart rendering problems #781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm thinking the solution is to use browser events - like #794. Here's the thinking: if you are "managing" the state of something (a check box, modal opened/closed, etc), you should choose to manage that either entirely client-side with custom JS or server-side with LiveComponents. In your situation, since you have Stimulus code to handle things, in your I've done the same thing recently for a modal: I use Bootstrap's native JavaScript on a link to open a modal - no LiveComponents code needed for that part. Then, via a child component that lives in the modal, when I submit to a Thoughts? |
Hmm :) that's optimistic. I want stimulus controllers to be agnostic from live components, so in this case checkbox controller listens only for With modals I currently chose an |
You're not really binding your Stimulus controllers to live components - you're giving them an extra hook point (e.g. if someone dispatches an Assuming your Stimulus controller IS on the same element (or a parent) of the live component root element, you could do something like this to pull this off: // in connect()
this.element.addEventListener('check:uncheck', (event) => {
// pretend you pass a "value" to dispatchBrowserEvent with the value of the item that should be unchecked
const targetedValue = event.detail.value;
const checkbox = this.element.querySelector(`input[type="checkbox"][value="${targetedValue}"]`);
checkbox.checked = false;
}); Still not the MOST elegant thing - but let me know what you think. |
Thanks, but I will need more time to check this as I'll be off for a week, so will get back to you later. |
Yes, in backend I use
html_classes
to apply them based on states.The component was made to work without live components - so for UI to know what color class to apply on checkbox If it's checked I need to expose it to stimulus.
So now with in a different part of app it was integrated into a live component and then the problem arose. And yes - it is to make experience feel faster :)
The text was updated successfully, but these errors were encountered: