Skip to content

Instantly share code, notes, and snippets.

@dbouwman
Created February 7, 2014 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbouwman/8857184 to your computer and use it in GitHub Desktop.
Save dbouwman/8857184 to your computer and use it in GitHub Desktop.
Map Controls view with calls to log the event
Composer.module('MapBarModule.Controls', function (Controls, App, Backbone, Marionette, $, _) {
//Controls item view
Controls.View = Backbone.Marionette.ItemView.extend({
model: Controls.Model,
template: 'mapbar/controls/controls_view',
className: 'mapbar-controls',
events: {
"click .type": "_changeBasemap"
},
_changeBasemap: function(e) {
var id = e.target.id;
//toggle some classes to update the UI
this.$el.find('.type').removeClass('selected-type');
this.$el.find('#'+id).addClass('selected-type');
//log that the user did this action
App.logUiEvent(id, 'map-basemap');
//event bus call
App.execute('map:new:basemap', id.replace(/basemap-/, ''));
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment