-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
yield & component helper => two way data binding not working ? #13061
Comments
Can you try simply :
I find |
From the same documentation: "Contextual components are created using the nested form of the component helper, and may be passed attrs and positional params. Contextual components must be invoked with a . in their path, unless they are being passed to the invoking {{component helper." |
@plcarmel can you create an ember-twiddle example that demonstrate the issue? Also I'm curious if 2-way binding is supposed to function, the docs mention binding, but not 2-way. |
In the example given, a (custom) input component is used. So, it is implicit that two way binding should work in that example. There is no action registered on the component so one-way data binding would render the component useless. Anyway, things need to be clarified. I will create the Ember Twiddle soon (one week max), stay tuned. |
I may have found the same bug. I don't think |
@Serabe You have a lot of knowledge on |
Looking into it |
Yes, I think this is the same issue. |
TL;DR Found the issue. I think I fixed it but a few more tests are needed. I hope to have it done pretty soon. For normal component invocation, Ember adds a If everything goes ok, I hope to have it finished before next week. But again, only if everything goes ok. |
@Serabe Thanks for the update, and for working on it :) |
If you manually use |
Yes, it does. The problem is fixed but I need testing it a bit more before
pushing a PR
|
As explained in issue emberjs#13061, given a component `change-button` with template: ```hbs <button {{action (action (mut val) 10)}}>Change to 10</button> ``` If it is invoked as in the following template: ```hbs {{change-button val=value}} <span class="value"> {{value}} </span> ``` Clicking on the button will cause `.value` to contain `10`. On the other hand, invoking it via a closure component: ```hbs {{component (component "change-button" val=value)}} <span class="value"> {{value}} </span> ``` Clicking on the button will not change the text in `.value`. This PR adds a transform that adds `mut` to params and hash values.
As explained in issue #13061, given a component `change-button` with template: ```hbs <button {{action (action (mut val) 10)}}>Change to 10</button> ``` If it is invoked as in the following template: ```hbs {{change-button val=value}} <span class="value"> {{value}} </span> ``` Clicking on the button will cause `.value` to contain `10`. On the other hand, invoking it via a closure component: ```hbs {{component (component "change-button" val=value)}} <span class="value"> {{value}} </span> ``` Clicking on the button will not change the text in `.value`. This PR adds a transform that adds `mut` to params and hash values. (cherry picked from commit 31bb7a2)
As explained in issue #13061, given a component `change-button` with template: ```hbs <button {{action (action (mut val) 10)}}>Change to 10</button> ``` If it is invoked as in the following template: ```hbs {{change-button val=value}} <span class="value"> {{value}} </span> ``` Clicking on the button will cause `.value` to contain `10`. On the other hand, invoking it via a closure component: ```hbs {{component (component "change-button" val=value)}} <span class="value"> {{value}} </span> ``` Clicking on the button will not change the text in `.value`. This PR adds a transform that adds `mut` to params and hash values. (cherry picked from commit 31bb7a2)
Fixed in #13177 |
DEBUG: -------------------------------
DEBUG: Ember : 2.4.1
DEBUG: Ember Data : 2.4.0
DEBUG: jQuery : 2.2.1
DEBUG: -------------------------------
I don't know if this is a bug but it seems to contradict the documentation at
[http://emberjs.com/api/classes/Ember.Templates.helpers.html#toc_nested-usage]
This is the example that is given:
{{yield (hash nameInput=(component "my-input-component" value=model.name placeholder="First Name"))}}
I tried it but without being able to achieve two way data binding.
To replicate the problem
templates/components/test-binding.hbs:
{{yield (component 'my-input' value=value)}}
templates/components/my-input.hbs:
{{input value=value}}
templates/application.hbs:
A work-around
It works it the value is encapsulated inside a hash. Please note that the way I do it differs from the example in the documentation, which is not working.
templates/components/test-binding-2.hbs:
{{yield (component 'my-input-2' model=model)}}
templates/components/my-input-2.hbs:
{{input value=model.value}}
templates/application.hbs:
controllers/application.js:
The text was updated successfully, but these errors were encountered: