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?
Use this.options to retrieve argumentr in view
// Place holder
var showNameView = Backbone.View.extend({
el:'.contentName',
initialize: function(){
// Get name value by this.options.name
this.render(this.options.name);
},
render: function(name){
$('.contentName').html(name);
}
});
$(document).ready(function(){
// Passing name as argument to view
var myName1 = new showNameView({name: 'Nishant'});
});
Working Example: http://jsfiddle.net/Cpn3g/1771/