0
사용자는 양식 필드를 통해 조작 할 수 있습니다. 그러나 나는 그들을 어떻게 구원 할 수 있는지 알 수 없다. 언제는 User
의 lastName
을 변경하고 나는 다음과 같은 오류가 발생합니다 저장 버튼을 클릭 이제까지 :커밋/저장을 어떻게 트리거 할 수 있습니까?
Uncaught Error: Attempted to handle event `save` on <App.User:ember309:1> while in state rootState.loaded.updated.uncommitted. Called with undefined
내가 저장 버튼을 클릭하여 레코드를 저장 (커밋)로 변경해야합니까? index.html을
<script type="text/x-handlebars" data-template-name="users">
<table class='table'>
{{#each model}}
<tr>
<td>{{view Ember.TextField valueBinding='lastName'}}</td>
{{#with this as model}}
<td><button {{bindAttr class=":btn isDirty:btn-primary:disabled"}} {{action "save" target="model"}}>save</button></td>
{{/with}}
</tr>
{{/each}}
</table>
</script>
는
App = Ember.Application.create();
App.Store = DS.Store.extend({
revision: 12,
adapter: 'DS.FixtureAdapter'
})
App.Router.map(function() {
this.resource('users', function() {
this.resource('user', { path: ':user_id' })
})
});
App.UsersRoute = Ember.Route.extend({
model: function() {
return App.User.find();
}
});
App.UserController = Ember.ObjectController.extend({
save: function() {
this.commit();
}
})
App.User = DS.Model.extend({
lastName: DS.attr('string')
})
App.User.FIXTURES = [{
id: 1,
lastName: "Smith"
}]
당신이 저장하고자하는 기록을 지정하지 않기 때문에 어쩌면 있습니까? '{{액션 저장 모델}}'. – zeppelin
Ember-Data의 어떤 버전 (커밋)을 사용하고 있습니까? 'DS.Model'의'save' 메소드는 [36d2e2a07]부터 사용 가능합니다. (https://github.com/emberjs/data/commit/36d2e2a07a82cc67baab186c36c38c405186ac12#L1R292) – pangratz
방금 데이터 최신 버전으로 업데이트했습니다. 차이 없음. 100 % 고객 측의 MVC 구조를 아직 이해하지 못했습니다. 나는 그것이 아주 기본적인 실수라고 생각한다. – wintermeyer