そこには2つのビューがあります...あるビューから次のビューにデータを配置する必要がありますが、これをどのように実装できるかわかりません。
最初の関数ビューがあります:
var CategoriesView = Backbone.View.extend({ 
    initialize:function () {
    this.render();
},
render:function () {
    var that = this;
    var categories = new Categories();
    categories.fetch({
        success: function (categories) {
        var template = _.template($('#categories-template').html(), {categories: categories.models});
          that.$el.html(template);
        }
    })
}             
});
テンプレートがあります:
    <script type="text/template" id="categories-template">
        <% _.each(categories, function(category) { %>
            <li><%= category.get('name') %></li> 
        <% }); %>
    </script>
モデルとコレクション:
var Category = Backbone.Model.extend({
defaults: {
    name: 'Category',
    id: []
},
});
var Categories = Backbone.Collection.extend({
url: 'api/categories.json'
});
私が持っているjsonオブジェクト(すべてのカテゴリ)からのすべての名前:
<li>there</li> 
...各カテゴリに製品を実装する必要があります....そこに製品のリストがあります:
var ProductsView = Backbone.View.extend({ 
    initialize:function () {
    this.render();
},
render:function () {
    var that = this;
    var products = new Products();
    products.fetch({
        success: function (menus) {
        var template = _.template($('#products-template').html(), {products: products.models});
          that.$el.html(template);
        }
    })
}             
});
テンプレート :
    <script type="text/template" id="products-template">
        <% _.each(products, function(product) { %>
                <li class="productscls"><%= product.get('name') %></li> 
        <% }); %>
    </script>
モデルとクールレクション:
var Product = Backbone.Model.extend({
defaults: {
    name: 'Product',
    category: 1,
    id: []
},
});
var Products = Backbone.Collection.extend({
url: 'api/products.json'
});
これはすべて私のものは正しいと示されていますが、私がそこのようなものを作ろうとすると:
    <script type="text/template" id="categories-template">
        <% _.each(categories, function(category) { %>
                <li class="categorycls"><%= category.get('name') %></li>
            <% _.each(products, function(product) { %>
                    <li class="productscls"><%= product.get('name') %></li>
            <% }); %>
        <% }); %>
    </script>
そこで、私が作りたいものを見ることができます。各カテゴリの各製品について、これはカテゴリまたは製品ビューにデータを渡さないと機能しません....
よろしくマクロマット