Skip to content
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

elementId/viewName don't work #10954

Closed
knownasilya opened this issue Apr 24, 2015 · 10 comments
Closed

elementId/viewName don't work #10954

knownasilya opened this issue Apr 24, 2015 · 10 comments

Comments

@knownasilya
Copy link
Contributor

This used to work. Trying it with 1.11.3 currently.

{{input type='text' value=title viewName='titleInput'}}

{{! None of these work }}
<label for="{{titleInput.elementId}}">Title</label>
<label for={{titleInput.elementId}}>Title</label>
<label {{bind-attr for=titleInput.elementId}}>Title</label>

Even if I change the value of elementId, nothing, {{log}} logs undefined.
http://emberjs.jsbin.com/pofipodena/1/edit

@clekstro
Copy link

clekstro commented May 4, 2015

@knownasilya That JSBin doesn't appear to represent the issue. Could you update the link to a working example?

@sly7-7
Copy link
Contributor

sly7-7 commented May 12, 2015

@knownasilya I think you must prepend titleInput by view here. http://emberjs.jsbin.com/kucoburixu/1/edit

@knownasilya
Copy link
Contributor Author

@sly7-7 ah, that's new!

@sly7-7
Copy link
Contributor

sly7-7 commented May 12, 2015

@knownasilya I don't think it's new (at least since 1.8 or 1.9), when doing
{{input type='text' value=title viewName='titleInput'}}
you define a titleInput property on the current view, so in the template you must refer it by using view.titleInput.

@knownasilya
Copy link
Contributor Author

Maybe since it's not a component? Since components don't require the view. portion.

@sly7-7
Copy link
Contributor

sly7-7 commented May 12, 2015

Hm, yeah, if the current view is a component, maybe you don't have to put the view. prefix because the context is already the component, not the enclosing controller

@knownasilya
Copy link
Contributor Author

@sly7-7 so it sounds like a regression somewhere around 1.8/9 because view. was never required before, since I remember this.get('myViewName') from the controller, and it working.

@krisselden
Copy link
Contributor

If this particular example was supported in the past, it was an accident, if you move the label ahead of the input, you now will invalidate the rendering of the label you did when the input is created. This example is an anti pattern, you should give the label and input an id from the parent component instead.

@rwjblue
Copy link
Member

rwjblue commented May 18, 2015

I gave a fairly detailed description (based on a conversation with @krisselden) of using viewName for this over in #11156 (comment).


@knownasilya - Using view.fieldName has always been required. However, if you are in a component this happens to be the same as view so it works without the prefix. Take a look at http://emberjs.jsbin.com/qulere/1/edit?html,js for a demo of that.

I definitely suggest reviewing my reply in #11156 and updating to a more declarative syntax.

@rwjblue rwjblue closed this as completed May 18, 2015
@knownasilya
Copy link
Contributor Author

@rwjblue thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants