Skip to content

Instantly share code, notes, and snippets.

@kishalmi
Created May 21, 2014 14:19
Show Gist options
  • Save kishalmi/db5060b30de5fa9cbae0 to your computer and use it in GitHub Desktop.
Save kishalmi/db5060b30de5fa9cbae0 to your computer and use it in GitHub Desktop.
trapping TAB key in ember component input-helper
<script type="text/x-handlebars" id="components/chat-input">
{{input id="tiChatInput" action="chatInputEnter"}}
</script>
MyApp.ChatInputComponent = Ember.Component.extend({
didInsertElement: function () {
var self = this,
ctx = this.$('input').keydown(function (event) {
if (event.which === 9) {
// [TAB]
event.preventDefault();
self.send('chatInputTab', ctx.val());
}
});
},
actions: {
chatInputEnter: function (strInput) {
console.log('pressed [ENTER] in chatinput', strInput);
},
chatInputTab: function (strInput) {
console.log('pressed [TAB] in chatinput', strInput);
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment