How to pass parameters to a view

前端 未结 5 1344
梦谈多话
梦谈多话 2020-12-04 09:22

I have a series of buttons which when clicked display a popup menu positioned just below the button. I want to pass the position of button to the view. How can I do that?

5条回答
  •  一生所求
    2020-12-04 10:14

    pass from other location

     new MenuView({
       collection: itemColl,
       position: this.getPosition()
    })
    

    Add an options argument to initialize in view you are getting that passed variable,

    initialize: function(options) {
       // Deal with default options and then look at options.pos
       // ...
    },
    

    to get the value use -

       var v = new ItemView({ pos: this.options.positions});
    

提交回复
热议问题