EmberJs와 협력 중이며 다음 코드가 '새'템플릿을 렌더링하지 않는 이유를 알 수 없습니다./shop으로 이동하면 상점 목록과 '/ shops/new'에 연결되는 버튼을 만들지 만 create를 클릭하면 'new'템플릿이 렌더링되지 않고 'shops'와 동일하게 유지됩니다. . 나는 새로운 상점이 아니라 각각의 상점을 탐색 할 수있다.Emberjs가 잘못된 템플릿을 렌더링합니다.
App.js
window.App = Ember.Application.create();
App.Router.reopen({
location: 'history'
});
// Router
App.Router.map(function() {
this.resource('shops', function() {
this.route('new');
});
this.resource('shop', { path: '/shops/:shop_id' });
});
App.ShopsRoute = Ember.Route.extend({
model: function() {
return App.Shop.find();
}
});
App.ShopsNewRoute = App.ShopsRoute.extend({
model: function() {
return App.Shop.createRecord();
},
setupController: function(controller, model) {
return this._super(),
controller.set('content', model)
}
});
App.ShopsNewController = Ember.ObjectController.extend();
// Models
App.Store = DS.Store.extend({
revision: 11,
adapter: DS.RESTAdapter
});
App.Shop = DS.Model.extend({
name: DS.attr('string'),
body: DS.attr('string'),
});
Index.html을 당신이 shops.new
로 이동하고 유지하려면 당신의 경로와 템플릿을 설정하는 방법, 당신은 엠버을 말하고있다
<!DOCTYPE html>
<html>
<head>
<title>Ember/Rails App</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<script type="text/x-handlebars" data-template-name="application">
<div class="row">
<div class="twelve columns">
<h1>Ordr</h1>
<hr>
{{outlet}}
</div>
</div>
</script>
<script type="text/x-handlebars" data-template-name="shops/new">
<h2>New Shop</h2>
</script>
<script type="text/x-handlebars" data-template-name="shops">
{{#each shop in controller}}
{{#linkTo "shop" shop}} {{ shop.id }}{{/linkTo}}
{{/each}}
{{#linkTo 'shops.new'}}Create{{/linkTo}}
</script>
<script type="text/x-handlebars" data-template-name="shop">
<h2>{{name}}</h2>
<p>{{body}}</p>
</script>
</body>
</html>
멋진. 두 번째 대답은 제가 찾고 있던 것입니다. 감사합니다. – paulruescher