-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add context option for child views like in NestedView #2
Comments
Interesting. I suppose I never encountered that case. It also seems more brittle, and safer to explicitly pass in specific attributes. What's your use case? |
app/templates/places/list.hbs app/templates/places/place.hbs It's better if we can do that: app/templates/places/list.hbs app/templates/places/place.hbs |
Hmm. Well, typically you'd be working with models and collections, right? So you could do something like: {{#each places}}
{{view "places/place" model=this}}
{{/each}} |
app/templates/places/list.hbs app/templates/places/place.hbs I have this exception: |
It's working when I do that, tell me if it's a good usage. app/controllers/places_controller.js
app/views/places/index.js
app/templates/places/index.hbs
app/views/places/list.js
app/templates/places/list.hbs
app/views/places/place.js
app/template/places/place.hbs
|
I'm stumbling on the same issue. I tried your code. For the first instantiation, it seems fine. However, if I reload the same page (in rendr), then all of my models seem to equal the last model in the array. Caching issue? Also, curiously _models and _collection.models is not the same (first one will give me "toJSON error"). Are we doing something wrong? |
Looks like adding a idAttribute to my model (because they don't have an |
Good catch re: |
I found myself being able to nest views within loops like this:
And then, in xview.js:
Because in xview, this.model is just an array. |
+1 on this. This allows for a nice and clear encapsulation of model's view logic within a template (click handlers etc), without having to override the getTemplateData, or breaking convention (a view's |
Why you don't added context option binding for child views like in your NestedView plugin for Backbone ?
Example:
{{#each models}}
{{view "myChildView" context=this}}
{{/each}}
The text was updated successfully, but these errors were encountered: