Looks like we can't reproduce the issue or there's a problem in the test case provided.
Calling getViewModel().bind() before component is added breaks bind configs.
Calling getViewModel().bind() before component is added breaks bind configs.
As shown in this fiddle http://ift.tt/1HcrZSD
One can instantiate and then add() a component with bind configs to a view hierarchy. Upon add, the View Model does its thing and properly inherits view models from parent components. If one calls getViewModel().bind() on exactly the same path, not only doesn't it work but it breaks the bind configs that come later. The normal ViewModel inheritance stops working.
The hierarchy isn't setup properly, so when you're asking to bind to the value at that point, it has no knowledge of the higher up view models.
You need to wait until the hierarchy is completed before binding.
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
Evan,
I understand your explanation but then why does a bind config work? Does the implementation of bindable wait for "added" internally? Seems to me that ViewModel.bind() loses a lot of value if I can't use it in initComponent, or if I *always* have to guard it with on('added', ..);
Thanks!
[CLOSED] Calling getViewModel().bind() before component is added breaks bind configs.
Aucun commentaire:
Enregistrer un commentaire