Created
July 3, 2013 22:00
-
-
Save dznz/5923238 to your computer and use it in GitHub Desktop.
Autoselect select event problem
This file contains 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
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