Created
May 21, 2014 14:19
-
-
Save kishalmi/db5060b30de5fa9cbae0 to your computer and use it in GitHub Desktop.
trapping TAB key in ember component input-helper
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
<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