1
내 응용 프로그램에서 모든 것이 잘 작동하지만 브라우저 콘솔에 객체를 수동으로 추가하면 가져 오기에서 json 모델 데이터가 표시되지만 웹에서는 렌더링되지 않습니다. 페이지.백본에 json 콘텐츠를 표시 할 수 없습니다.
목록보기에서 노트보기를 호출하여 UL로 렌더링합니다.
이이 백본보기 스크립트 내 HTML 요소
<html>
<head>
<title> Backbone Demo </title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<script type="text/template" id="library-template">
<h1> My Notes List </h1>
<ul class="mynotes"></ul>
</script>
<script type="text/template" id="mynote-template">
<div class="mynote-title"> </div>
<div class="mynote-content"</div>
</script>
</head>
<body>
<div id="container">
</div>
</body>
</html>
입니다.
window.LibraryView = Backbone.View.extend({
tagName: 'section',
className: 'mynotes',
initialize: function() {
_.bindAll(this, 'render');
this.template = _.template($('#library-template').html());
this.collection.bind('reset', this.render);
},
render: function() {
var $mynotes,
collection = this.collection;
$(this.el).html(this.template({}));
$mynotes = this.$(".mynotes");
collection.each(function(mynote) {
var view = new LibraryMynoteview({
model: mynote,
collection: collection
});
$mynotes.append(view.render().edl);
});
return this;
}
});
콘텐츠 형식을 표시 할 수 있습니까? json 데이터는 어떻게 생겼습니까? – kaha