Open ceremcem opened 2 years ago
Note that if we don't use instance.partials.content[0]
and use instance.get('text')
, it works as expected (playground):
<radio-buttons on-select="radioSelected">
{{#each myArray}}
<radio-button text="{{.}}">{{.}}</radio-button>
{{/each}}
</radio-buttons>
So the problem is that we can't get the "content" of a component when it's created by a loop.
Since content
is a partial, it can be any template. In the case of loop, the content is an interpolator that references .
. As template content, there isn't really a value associated with it until it's rendered, so there are two things you could do:
I suppose you could also combine those in something like this.
Description:
I've my reasons to re-invent the radio buttons with
<button>
elements (like displaying "loading" icon and confirming database writes before displaying a "selected" tick). This is the stripped down version of myradio-buttons
component (playground):However, when I try to create the
radio-button
s with an{{#each}}
loop, buttons'on-click
handler doesn't work as intended: playground:Expected output when we click on
[a]
button:selection is: a
Observed output is:selection is: undefined
How can I make it work when I create the sub-components dynamically? What becomes different when we encapsulate the sub-components into the
{{#each}}
loop?Versions affected:
1.4
Platforms affected:
Browser