Skip to content

Commit

Permalink
Merge pull request emberjs#1163 from ghempton/context-fix
Browse files Browse the repository at this point in the history
Fixed view context lookup issue.
  • Loading branch information
krisselden committed Jul 13, 2012
2 parents d0fd522 + fac3864 commit 7d0d836
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ember-handlebars/lib/helpers/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ EmberHandlebars.ViewHelper = Ember.Object.create({

// We only want to override the `_context` computed property if there is
// no specified controller. See View#_context for more information.
if (!newView.proto().controller && !newView.proto().controllerBinding && !viewOptions.controller && !newView.controllerBinding) {
if (!newView.proto().controller && !newView.proto().controllerBinding && !viewOptions.controller && !viewOptions.controllerBinding) {
viewOptions._context = thisContext;
}

Expand Down
15 changes: 15 additions & 0 deletions packages/ember-handlebars/tests/helpers/each_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,19 @@ if (Ember.VIEW_PRESERVES_CONTEXT) {
equal(view.$().text(), "AdamSteve");
});

test("controller is assignable inside an #each", function() {
var controller = Ember.ArrayController.create({
content: Ember.A([ { name: "Adam" }, { name: "Steve" } ])
});

view = Ember.View.create({
controller: controller,
template: templateFor('{{#each itemController in this}}{{#view controllerBinding="itemController"}}{{name}}{{/view}}{{/each}}')
});

append(view);

equal(view.$().text(), "AdamSteve");
});

}

0 comments on commit 7d0d836

Please sign in to comment.