Ember {{#with ... controller=...}} gives "Uncaught TypeError: Cannot read property 'lookupFactory' of undefined"

StackOverflow https://stackoverflow.com/questions/23298656

سؤال

I'm trying to access properties of a controller (actually a mixin extended by a controller) in Ember, and I need to use the {{#with}} handlebars helper. I get the error:

Cannot read property 'lookupFactory' of undefined

The place I'm trying to specify the controller for each looks like this:

{{#with orders.order controller='ordersIndex'}}

I have also tried just about every combination I can think of:

{{#with orders.order controller='orders'}}
{{#with orders.order controller='Orders'}}

Tried specifying the controller for the route that seems to work:
{{#with orders.order controller='brokerageAccount'}}
{{#with orders.order controller='BrokerageAccount'}}
{{#with orders.order controller='Brokerage'}}

No luck with any of them.

All Code is in JSBin: http://emberjs.jsbin.com/cabak/1/edit?html,js

Output view of the two routes:

Broken one: (here if you open the console, you'll see the error) http://emberjs.jsbin.com/cabak/1#/orders

This one works: you'll see some data. http://emberjs.jsbin.com/cabak/1#/orders/tradier/12345

هل كانت مفيدة؟

المحلول

I guess there is a bug with the {{with}} helper, because if you use the {{#each elem in model}} and update the {{with}} to use the elem variable: {{#with elem.orders.order controller='ordersIndex'}} all works.

This is the updated orders/index template:

 <script type="text/x-handlebars" data-template-name="orders/index">
  <div class="inline-headers">
    <h4><label>Brokerage: </label>{{titleize brokerage}}</h4>        
  </div>
  {{#each elem in model}}
    <h4 class="account-header"><label>Account: </label>{{account_number}}</h4>
    {{#with elem.orders.order controller='ordersIndex'}}
      {{partial "_orders_table"}}
    {{/with}}
  {{/each}}
</script>

And this is the updated jsbin http://emberjs.jsbin.com/piwuyare/1#/orders

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top