Skip to content

Instantly share code, notes, and snippets.

@GorosVi
Last active September 21, 2015 22:13
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 GorosVi/e50ea8eacd5520ebba39 to your computer and use it in GitHub Desktop.
Save GorosVi/e50ea8eacd5520ebba39 to your computer and use it in GitHub Desktop.
Widget test
define(['lib'], function (lib) {
var SetterWidgetView = lib.marionette.ItemView.extend({
template: lib.handlebars.compile(
'{{displayName}}' +
'<div class="btn-group-justified">' +
'<a href="#" class="btn btn-default nooui-button js-btn-set" data="0"> On</a>' +
'<a href="#" class="btn btn-default nooui-button js-btn-set" data="100"> Off</a>' +
'</div>'),
className: 'nooui-widget',
events: {
"click .js-btn-set": "btnSetClick",
},
btnSetClick: function (e) {
this.trigger('setter:set',e);
}
});
var sendCommand = function (cmd, value) {
var req = $.getJSON('/api/noolite?ch=' + '&cmd=on');
console.log(req);
}
var setterSet = function (brightness) {
console.log( brightness.target.data);
sendCommand(6, 0);
};
return {
show: function (model, region) {
var view = new SetterWidgetView({ model: model });
view.on("setter:set", setterSet);
region.show(view);
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment