-
-
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
dynamic binding declaration ("dereferenced" binding) #4619
Comments
i kinda like the idea of: {{#each field in fields}}
{{field}}: {{input type="text" value=*field}}<br>
{{/each}} |
won't this be easy to do once we have sexpr? |
Everything will be easy (and fugly) once we have s-expressions. I think a dereferencing operator makes total sense as a meaningful shorthand. |
I move that we NOT call them sexpressions |
@endash ya, we should call them s-expressions instead. |
We don't need another ExpertSexChange on our hands. |
Could someone point me in the right direction within the Ember codebase for making this feature addition? |
@stefanpenner is this something you could provide guidance on? |
I was just looking for an answer for this exact problem, I have dynamic fields I need to enumerate and build a form with input controls. It seems helpers don't get the value of the variable from I was however able to figure out an interim solution for my custom input helper which allows me to dereference the
Note I am NOT using I would be keen to know where to start implementing general dereference support for bound properties but nothing particularly obvious jumped out on my initial scan through the code. @stefanpenner any heads up on where to start with this? |
UPDATE: I was able to extract my initial solution into a standalone general purpose helper that can dereference a variable for use within the context of another helper. Use as follows:
Helper:
So my questions:
|
@ahacking Yes, there is a nice solution using subexpressions and streams that doesn't use the |
@mmun Thanks, I guess I'll wait for the eventual 1.9 release to settle before cutting across to the new goodness as I have something that is functioning now and don't want to risk stability. |
@ahacking Basically it would look like this: {{input type="text" value=(deref field)}} import { read } from "ember-metal/streams/read";
export default function derefHelper(params, options) {
var view = options.data.view;
var key = read(params[0]);
return view.getStream(key);
} With a little more work we could make it bound (e.g. if |
@mmun thanks for that. Can I ask is there any documentation on the streams stuff? Please pardon my ignorance as I am not aware of the features and benefits that the new streams work provides. |
@ahacking There isn't any documentation yet. The stream rewrite is on canary and will be in 1.9, but it's still a private/internal API. The benefits are that is simplifies a lot of the template binding code and makes it simpler to generalize. For example, currently the query-params helper implementation has to manage all of its own bindings because it hasn't been streamified yet. If you're interested, you could work on that. You can find me on #emberjs as mmun if you want to chat. |
@mmun Thanks, when my workload lightens I will see what I can do. |
This is possible now: http://rwjblue.jsbin.com/gavana/edit?html,js,output
|
Is there currently a way to declare a binding to a dynamically assigned property name in a template?
Here is a contrived example:
The resulting input elements should be bound to the
name
andemail
properties of the application controller instance used as context for the template.Here is a JSBin showing that this does not currently work:
http://jsbin.com/toyih/8
If there is not currently a way to do this, would the Ember team be open to a PR that introduces a dereferencing operator as I've shown above? If yes, where is the logic for *Binding?
The text was updated successfully, but these errors were encountered: