简体   繁体   中英

Custom element two-way binding update without triggering valueChange

I have a situation here, the valueChanged gets called even if I change the bindable property value internally within custom element. How do I send the updated value back to viewModel from custom element without triggering valueChanged for that bindable value.

is there a way to supress this? or I have to use internal tracking if this is called from internal code or coming from view?

There is no way to prevent a bindable property's change handler method from being called based on whether the custom element's own code is assigning the property or whether it's being assigned by external code or in response to user input. You will have to roll your own internal tracking mechanism.

As Jeremy said, there's no way to prevent a bindable property's change handler from being called. However, you could attach or trigger your code only with the form input using the change.delegate or keyup.delegate properties. That would allow you to isolate your event code from the changes resulting from binding properties.

Here's a GistRun to demonstrate this:

https://gist.run/?id=11cd1e90dd912f07a60afaedb9c2613b

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM