Menu Button display with main and sub categories using backbone.js

天涯浪子 提交于 2019-12-23 04:55:10

问题


I have a menu button where i have render main categories and on mouse over need to render its subcategories.Now i am able to render the main categories but not subcategories.

This is my View.

 var Product_View = Backbone.View.extend({
                tagName: 'div',
                className: 'products',
                initialize: function (options) {
                    this.options = options || {};
                },
                events: {
                    "mouseover #category_menu" : "test"
                },
                test: function(){
                    alert('here...');
                   //need to add code to render the sub categories here
                },
                render: function() {
                    _.templateSettings = 
                        {
                            evaluate:    /\{\{(.+?)\}\}/g,
                            interpolate: /\{\{=(.+?)\}\}/g
                        };
                  var compiled = _.template(this.options.temp);   
         document.getElementById(this.options.target).innerHTML=compiled({model:this.model.toJSON()});
                  return this;
                }

        });

here i am calling render method to list main category

  var category_menu = new Models.ProductView({
                    model : itemcollection,
                    temp : template,
                    target : "category_menu"
                });

                category_menu.render();

and tender template is like this

{{ _.each(model, function(item) { }}
<a href="#" id="{{=item.name}}">{{=item.name}}
{{ });}}

now i am getting main categories but not able to render subcategories

来源:https://stackoverflow.com/questions/27270322/menu-button-display-with-main-and-sub-categories-using-backbone-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!