Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function() {
- // Proof of concept
- var handleCurrentInput = function (e) {
- var $this = $(this),
- valStr = $this.val(),
- valArr, lastIndexAt, lastItem;
- if ( e.shiftKey && e.which === 50 ) {
- lastIndexAt = valStr.lastIndexOf('@');
- valArr = valStr.split('@');
- lastItem = valArr.pop();
- // fake logic that pretends to be twitter user autocomplete
- valArr.push('@user ')
- valArr.push(lastItem);
- $this.val(valArr.map(function(str) {
- return $.trim(str);
- }).join(' '));
- }
- };
- $('textarea')
- .bind('keyup', handleCurrentInput)
- .trigger('focus');
- });
Add Comment
Please, Sign In to add comment