jQuery UI widget factory _on hates events with hyphens.. ?
HTML
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<div id="thing">thing</div>
JavaScript
// Custom events with hashes in their name don't get triggered??
$.widget('ui.Thing', {
_create: function () {
this.element.text('THING LIVES');
this._on({
'click': function () {
var text = this.element.text();
this.element.text(text + ' click!');
},
'foo': function () {
var text = this.element.text();
this.element.text(text + ' foo!');
},
'foo-bar': function () {
var text = this.element.text();
this.element.text(text + ' FOO-BAR??');
}
});
var that = this;
this.element.on('phu-baz', function () {
var text = that.element.text();
that.element.text(text + ' PHU-BAZ?????');
});
}
});
$('#thing').
Thing().
trigger('click'). // works! :D
trigger('foo'). // works! :D
trigger('foo-bar'). // ..doesn't work?? :/
trigger('phu-baz'); // ... but THIS works??!? (╯°□°)╯︵ ┻━┻