Skip to content

Instantly share code, notes, and snippets.

@dznz
Created July 3, 2013 22:00
Show Gist options
  • Save dznz/5923238 to your computer and use it in GitHub Desktop.
Save dznz/5923238 to your computer and use it in GitHub Desktop.
Autoselect select event problem
Form.editors.AutoSelect = Form.editors.Text.extend({
initialize: function(options) {
var _this = this;
Form.editors.Text.prototype.initialize.call(this, options);
this.$el.autocomplete({
...
select: function(event, ui) {
_this.setValue(ui.item);
return false;
}
});
}
...
}
test('select event calls out', function() {
var editor = new Editor().render();
$('#qunit-fixture').append(editor.el);
sinon.stub(editor, 'setValue');
editor.$el.on( 'autocompleteselect', function() {
ok( true, 'editor was selected');
});
// editor.$el.trigger('select');
editor.$el.trigger( $.Event('autocompleteselect') );
ok(editor.setValue.called, 'called setValue');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment