ember.js: my bindings are working in a context but not in another -
i have chunk of code working in simple environment:
here index.hbl
{{view app.searchinvoicableproductformview}}
here view
app.searchinvoicableproductformview = em.view.extend templatename: 'search_invoicable_product_form' invoicablesearch: "search..."
here template search_invoicable_product.hbl
:
{{view ember.textfield valuebinding="invoicablesearch" size="8"}}<br /> {{#each invoicable in results}} {{invoicable.name}}<br /> {{/each}}
and here controller:
app.indexcontroller = ember.controller.extend invoicablesearch: "cerca..." results: (-> if @get("invoicablesearch").length > 3 app.invoicable.find(q: @get("invoicablesearch")) ).property("invoicablesearch")
in context working fine. when type text field search performed
while in context bindings not work:
i'm @ path: invoices/new
here router:
app.router.map -> @resource "invoices", -> @route 'new'
here routes:
app.invoicesroute = ember.route.extend model: -> app.invoice.find() app.invoicesnewroute = ember.route.extend model: -> app.invoice.createrecord()
here controller:
app.invoicesnewcontroller = ember.objectcontroller.extend invoicablesearch: "search..." results: (-> if @get("invoicablesearch").length > 3 app.invoicable.find(q: @get("invoicablesearch")) ).property("invoicablesearch")
here views:
app.invoicerowformview = em.view.extend templatename: "invoices/invoice_row_form" app.searchinvoicableproductformview = em.view.extend templatename: 'invoices/search_invoicable_product_form'
ans here templates:
invoices.hbl
{{#each controller}} ... {{/each}} {{outlet}}
invoice.hbl
<form> {{partial 'invoices/form'}} </form>
invoices/form.hbl
...form invoice... {{partial 'invoices/invoice_rows'}}
invoices/invoice_rows.hbl
{{#each invoicerows}} {{view app.invoicerowformview}} {{/each}}
invoices/invoice_row_form.hbl
... {{view app.searchinvoicableproductformview}} ...
invoices/search_invoicable_product_form.hbl
{{view ember.textfield valuebinding="invoicablesearch" size="8"}}<br /> {{#each invoicable in results}} {{invoicable.name}}<br /> {{/each}}
in conclusion: moved same code in deeper position application. code of invoices/search_invoicable_product_form.hbl not changed, code app.invoicesnewcontroller, same of code inside indexcontroller.
but lost bindings
you need pass along controller each of these views, think. try this:
{{#each invoicerows}} {{view app.invoicerowformview controllerbinding="this"}} {{/each}}
Comments
Post a Comment