javascript - Ember set belongsTo associantion works only first time -


This code should provide the user a screen to update the template of your portfolio.

In this screen the server always gives 5 templates and the portfolio already has a template associated.

Model

  App.Portfolio = DS.Model.extend Color: DS.attr 'string' Template: DS.belongsTo 'template' App.Template = DS.Model.extend Title: DS.attr 'string' Portfolio: DS.hasMany ('template')   

Route App.PortfolioRoute = Ember.Route.extend setupController: (Controller, Model) - & gt; This._super (controller, model); Load all the templates for the #Proplio Screen Controller. Templates, this.store.find 'template'

Controller

  PortfolioApplication Portfolio Controller = Ember.ObjectController.extend Selected Template: Empty Examination Template Selection: (- & gt; @set 'model.template', @get ('selectedTemplate') console.log @get 'selectedTemplate' console.log @get ' Model 'console.log' -------- '.).'. ' Changes selected 'template actions: changeTemplate: (template) - & gt; @set 'selectedTemplate', template   

portfoloh.hbs

  {{# tmpl}} in all templates & lt; Button {{Action 'ChangeTemplate' tmpl}} & gt; {{Tmpl.title}} & lt; / Button & gt; {{/ Every}} & lt; H3 & gt; Template {{template.title}} & lt; / H3 & gt;   

This code works fine, while the user chooses a new template for the current portfolio. Example:

  • Open Portfolio with Template 1
  • Change to Template 2
  • Save

    But this Examples:

    • Open Portfolio with Template 1
    • Change to Template 2
    • Change to template 1 again does not work

      In the previous three steps, the screen is not updated and console logs:

        selectedTemplate.id = & Gt; 1 model.teplate.id = & gt; 2 --------   

      that is, @set 'model.template', @get ('selectedTemplate') has not been updated < Code> template property of portfolio

      I am stuck in this bug. Any help?

      This is a bug in amber data that has been set in the master

      See my JSBin to reproduce the issue

      You can comment / simulate the version of amber data and re-issue that issue again. Can generate > Besides, I had to fix my code to make it work:

      • I load RSVP.hash to templates To do model hook in portfolio you can set store.find in setupController
      • to No calls should be made to load portfolio in . In templates the template and template and templates .
      • > You can make a dependency between needs
      • to set the template to the supervisor on the model, you can do it directly in the action handler.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -