-
-
Notifications
You must be signed in to change notification settings - Fork 104
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
Feature request: element.ref in repeat.for, with.bind #376
Comments
I thought that using a ref there would attach it to the todo... |
I'm referring to the repeat and with cases. |
https://gist.run/?id=4f6ba08fbea90d3a02ec4f59759f249d <template>
<div with.bind="person" element.ref="el">
${firstName} ${middleName} ${lastName}
</div>
app.el = ${el}<br/>
person.el = ${person.el}
</template> Result: Mathew James Davis
app.el =
person.el = [object HTMLDivElement] This is what I would expect the behavior to be. @davismj is this your expectation as well? If not, you could use |
whoops hit wrong button |
Thanks @jdanyow , works like charm with repeater as well (what @davismj initially asked for): https://gist.run/?id=3e7f173cafba1b01deb323d5c864163d :) |
I can't get this behavior with |
https://gist.run/?id=1cb2ce7662e84e333b65d4f687d3a30f&sha=0bfa8bb8b7088305f4a8d2b2d791cfed9394b2d6 In the gist ^^^ the root/app binding context has <div repeat.for="person of persons" element.ref="el">
${person.firstName} ${person.middleName} ${person.lastName}
</div> this creates a series of child binding contexts which have Does that make sense? |
Not entirely. I would expect this block of code to put an <div repeat.for="person of persons" element.ref="el">
${person.firstName} ${person.middleName} ${person.lastName}
</div>
So if I follow you, then I can do this: <div repeat.for="person of persons" element.ref="el">
${person.firstName} ${person.middleName} ${person.lastName}
Element: ${el}
</div> If so, then from what I know of the binding system, I sort of understand what's happening, but I don't think this is a desired behavior. I can't imagine a use case for this. What do you think? |
The <div repeat-WITH.bind="persons" element.ref="el">
${firstName} ${middleName} ${lastName}
Element: ${el}
</div> Instead of doing what is currently supported: <div repeat.for="person of persons" element.ref="person.el">
${person.firstName} ${person.middleName} ${person.lastName}
Element: ${person.el}
</div> Does that sound about right? |
<div repeat.for="person of persons" element.ref="person.el"> Never seen that before, that was what I was looking for. |
I'm finding that I need to track the elements associated with various pieces of data that are getting bound throughout my view model. Aurelia only provides methods for accessing elements at the root view model, either through
element.ref
or through injecting anElement
.I'd like to propose that we have element.ref hoist to the closest binding context change, specifically either
repeat.for
orwith.bind
. That is:The text was updated successfully, but these errors were encountered: