Open ausminternet opened 9 years ago
I think developers need to add tabindex="" to dropdown list, focus it on visible and focus field back when hide. But now I did this:
var viewJustHid = false;
$element.on('hidden.atwho', function() {
viewJustHid = true;
setTimeout(function() {
viewJustHid = false;
}, 100);
});
$element.on('keydown', function(event) {
if (event.which == 13 && !event.shiftKey && !event.ctrlKey && !event.metaKey) {
event.preventDefault();
if (!viewJustHid) {
submit();
}
}
});
This is how i resolved it: http://jsbin.com/gabuwetowu/edit?html,console,output Its nearly the same as grammka his one, only i use the isSelecting event to check if the user is doing a @ mention. I think i prefer grammka his one, and might change my solution so i can drop my keyuplistener.
Hi there,
I have a form with a hidden field and an contenteditable div. I bound the enter-key to the contenteditable, to put it's text to the hidden filed and submit the form.
Now on selecting an element from the atwho.js dropdown with the enter-key will insert the atwho.js element AND submit the form. Any ideas how to prevent the enter to submit the form, when it was used to select from atwho list?