Ember.js View not displaying Ember.TextField {{vie

2019-09-01 08:47发布

问题:

I want to show this input so I may edit a category's 'Name', but the view is not displaying.

The result is only the Names for each Category appearing on the list. Each category should have it's own input with a value set to the 'Name' for that Category.

I am not receiving any errors, so what am I doing incorrectly?

  {{#each}}
   <tr>
     <td>
      {{view Ember.TextField valueBinding="Name" name="Name"}}
      <label class="category-text">
        {{#linkTo 'category' this}}
          {{Name}}
        {{/linkTo}}
      </label>
     </td>
  </tr>
{{/each}}

EDIT:

I've been playing around with implementing different input methods and none of them are showing up on the list of Categories! Waaah?

Here's what I tried:

<input type="text" Value="Name">

,

{{input type="text" valueBinding="Name" name="Name"}}

EDIT2:

VpcYeoman.CategoriesRoute = Ember.Route.extend({
    model: function() {
        VpcYeoman.Category.FIXTURES=[];
        $.ajax({
            url: '/categories',
            dataType: 'json',
            type:"get",      
            async: false,
            success : function(data) {      
                VpcYeoman.Category.FIXTURES=data;
            }
        });
        return this.store.find('category');
    }
}); 

and

model: function() {
  return this.store.find('category');
},

回答1:

Don't think using Ember.TextField directly is recommended anymore, you should use {{input value=name}} instead. More documentation on the input helper here.



回答2:

Here's a working JSBin for what you're trying to do. I'm not sure at which point you're having trouble, but you should try to match your system to be something like this.