Skip to content

Problems with linkTo which uses needs in application controller/templates #1812

@rlivsey

Description

@rlivsey

tldr - fiddle me this: http://jsfiddle.net/rlivsey/bjfDk/

The app has a contextual navigation bar for the current project in the application template:

+------------------------------------------------+
|   {{#if currentProject}} project nav {{/if}}   |
|------------------------------------------------|
|+----------------------------------------------+|
||                                              ||
||                                              ||
||                {{outlet}}                    ||
||                                              ||
||                                              ||
|+----------------------------------------------+|
+------------------------------------------------+

This gets the currentProject from the projectController via needs:

App.ApplicationController = Ember.Controller.extend({
    needs: "project",
    currentProjectBinding: "controllers.project"    
});

However is seems that currentProject is always truthy and so the project navigation always appears (I assume because the controller exists, even though it has no content). Binding instead to controllers.project.content toggles as expected, but I don't think we should have to do that?

{{linkTo}}'s in the navigation bar in the application template using currentProject break in a number of ways:

  1. the href doesn't update when currentProject changes, but the contents of the link do
  2. clicking the links raises "Uncaught RangeError: Maximum call stack size exceeded"

The fiddle shows these issues in action: http://jsfiddle.net/rlivsey/bjfDk/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions