Last active
September 21, 2015 22:13
-
-
Save GorosVi/e50ea8eacd5520ebba39 to your computer and use it in GitHub Desktop.
Widget test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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