Sha256: 0a71b25fb7692c1fd4bcfe5e2f6a711492dc3cd7cee7fedd601a1fcbe4dede03
Contents?: true
Size: 1007 Bytes
Versions: 85
Compression:
Stored size: 1007 Bytes
Contents
pageflow.SelectButtonView = Backbone.Marionette.ItemView.extend({ template: 'templates/select_button', className: 'select_button', ui: { button: 'button', label: 'button .label', menu: '.dropdown-menu', dropdown: '.dropdown' }, events: { 'click .dropdown-menu li': function(e, x) { e.preventDefault(); var index = getClickedIndex(e.target); this.model.get('options')[index].handler(); function getClickedIndex(target) { var $target = $(target), index = parseInt($target.data('index'), 10); if (isNaN(index)) { index = parseInt($target.find('a').data('index'), 10); } return index; } } }, onRender: function() { this.ui.label.text(this.model.get('label')); this.model.get('options').forEach(this.addOption.bind(this)); }, addOption: function(option, index) { this.ui.menu.append('<li><a href="#" data-index="'+ index +'">' + option.label + '</a></li>'); } });
Version data entries
85 entries across 85 versions & 1 rubygems