#Entangle doesn't call hooks?

76 messages · Page 1 of 1 (latest)

worldly marlin
#

I have a an entangled property show, but if I put updatedShow in my component it's never called (confirmed via Ray).

Is this intentional?

My use case is that I want to emit an event to a parent component when show changes and I was hoping to have it in PHP land not Alpine land

warm crane
#

Should work! Can you share your code?

worldly marlin
#

sure!

warm crane
#

Not using defer or anything?

worldly marlin
#

oh I am using defer

warm crane
#

Yep that’ll do it. Entangle makes use of it

worldly marlin
#

this is AlpineJS components...why the defer there? Do I need it?

warm crane
#

If it is on the wire:model it gets passed through to the alpine component

#

And it’s probably there to stop network requests when alpine opens the modal

worldly marlin
#

so, what's the solution here then?

#

don't make me emit in alpine josh

warm crane
#

Well… that’s how I do it 😆😆

#

Saves having the extra request too

worldly marlin
#

sigh, make this even harder to read...sigh

#

I blame you josh

warm crane
#

hides 😂

worldly marlin
#

so if I take the defer off it'll work, but what are the consequences?

warm crane
#

Are you just refreshing the parent when the modal is saved? Can you dispatch an event then?

worldly marlin
#

right now I have this in the parent

warm crane
worldly marlin
#

so I'd like to keep that in sync. If I don't have that if then there's a flash of the dialog

#

i'd rather NOT have that if, of course

warm crane
#

Ah yep. So I don’t conditionally add the modal compnent, I always have it on the page and toggle show inside of it instead of keep in sync with parent

worldly marlin
#

ya but then I got a flash of the modal

warm crane
#

On page load? Use x-cloak

worldly marlin
#

duh

#

sigh

#

that's what I get for coding on vacay w/ margaritas

warm crane
#

Haha nah that’s the best time to do it!

worldly marlin
#

only works if there's a josh around

warm crane
#

Why you coding in vacay? Fun personal project or work l?

worldly marlin
#

fun startup

#

like my own startup

warm crane
#

Ah well that’s alright then 😁😁

worldly marlin
#

so then to open it I need to send an event in or something?

#

how do you trigger the open from the parent?

#

same way I have it?

#

just remove the conditional?

warm crane
#

Yeah I tend to use alpine, but I dispatch a browser event on edit click which has the item id as a parameter and just listen for that event in the modal component

worldly marlin
#

right, in my case maybe two diff event, one for edit and one for new, but ya, that's nice

warm crane
#

Yep that’s how I do it. create-item and edit-item

worldly marlin
#

oh i'm getting closer to "being josh"

#

nice

warm crane
#

Haha yep! 😂

worldly marlin
#

since you're here, one other question maybe...how do you handle making the modal readonly?

#

in my case these are past events, can't be edited

warm crane
#

So like just a display modal instead of containing a form?

worldly marlin
#

ya

#

hoping not to duplicate

warm crane
#

Probably two seperate compnents 😆

worldly marlin
#

HECK W U JOSH

warm crane
#

Haha 😂

worldly marlin
#

(that's what I thought you'd say)

warm crane
#

Or you could just disable inputs based on a condition or computed property. And also add validation in your save method it make sure it can be edited

worldly marlin
#

I suppose I could update the components to take a readonly param

#

ha, there we go, same same

warm crane
#

Yup!

worldly marlin
#

again, I'M JOSH NOW

warm crane
#

🥳

worldly marlin
#

thanks again josh, you're so helpful

warm crane
#

No worries! 🙂

#

I need to find a way to teach people this stuff, how to structure components, etc

worldly marlin
worldly marlin
warm crane
#

Yeah I should start writing on my blog again 😆 but yeah was thinking some kind of workshop

sacred nimbus
#

@warm crane I believe people would actually learn a thing or two from you 🙂

worldly marlin
#

Thanks!

worldly marlin
#

much nicer solution, thanks josh

warm crane
worldly marlin
#

...well the alpinejs component