ManuelDeLeon / viewmodel

MVVM for Meteor
https://viewmodel.org
MIT License
205 stars 23 forks source link

vm bindings disappear from dom elements #222

Closed avalanche1 closed 8 years ago

avalanche1 commented 8 years ago

If I have a dom element with a vm binding enclosed in {{if currentUser}} condition, elements get unbinded whenever user is logged-in or out. Check here If you press login or logout the div with text disappears whereas it should change. I didn't test it with other if conditions but I think it's a generic problem.

avalanche1 commented 8 years ago

Maybe that's the same issue as https://github.com/ManuelDeLeon/viewmodel/issues/220

daveeel commented 8 years ago

If you have a condition block, the VM inside (or Blaze instance) is not created unless after the condition is true. You could check if that VM exists first, before trying to do anything.

ManuelDeLeon commented 8 years ago

I think they mean the event handler isn't there when the condition is true. I'll try one more thing and if that doesn't work I'll say F! It and revert all these changes and be incompatible with Astronomy and tap i18n. On Apr 1, 2016 7:50 AM, "Dave Lee" notifications@github.com wrote:

If you have a condition block, the VM inside (or Blaze instance) is not created unless after the condition is true. You could check if that VM exists first, before trying to do anything.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/ManuelDeLeon/viewmodel/issues/222#issuecomment-204403242

daveeel commented 8 years ago

@ManuelDeLeon , I have a weakly related question (not issue), sounds like the opposite. e.g. I have a template with a form. The form contains repeating subforms. Say Driver1, Driver2, etc. When uses want to input Driver2, I turn on a condition, and Driver2 renders. When user try 'Remove' Driver2, I'd like reset Driver2 form and hide it. Hiding is fine. Problem is the subform elements are all components (controls) with parameters passing in data. Calling reset() will lost the data passed in and fall back to default props in the raw components. That renders the form useless. Of course I could manually 'reset' the fields in the components. I'm wondering what's the best approach to achieve this in VM. Is there a way to re-Render a component with the initial parameters ? Thanks.

avalanche1 commented 8 years ago

Maybe vm should rebind itself after a flush?...

daveeel commented 8 years ago

Yes, for my use case, that would be very useful if the component (control) could be rebined after reset()

On Fri, Apr 1, 2016 at 10:28 PM, Artem Saffron notifications@github.com wrote:

Maybe vm should rebind itself after flush?...

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/ManuelDeLeon/viewmodel/issues/222#issuecomment-204416985

ManuelDeLeon commented 8 years ago

Reopen if it doesn't work in v4.0.11

ManuelDeLeon commented 8 years ago

@daveeel I think I follow but make a simple repro and open an issue.

avalanche1 commented 8 years ago

Funciona como un reloj :+1: But where are all the b-id attributes? :eyes:

ManuelDeLeon commented 8 years ago

I got rid of them as part of the rage I got into because of these series of issues essentially triggered by how other packages destroy and recreate elements, and then mess up onViewReady.

avalanche1 commented 8 years ago

I got rid of them as part of the rage Hehe!

But tap:i18n remains compatible? I was planning on using it when I go global (whoa!)

ManuelDeLeon commented 8 years ago

It does work with tap:i18n and all its shenanigans...

avalanche1 commented 8 years ago

Yeah, I feel you. We all go through ordeals caused by others sometimes...