Sunday, 11 August 2013

DIV contenteditable focus not working properly on iOS

DIV contenteditable focus not working properly on iOS

I have a DIV contenteditable on my page which is pretty important (link
recognition, maxlength, removing of formatting etc). On every plattform I
tested, it works perfect, except iOS, where there sometimes (almost
everytime) I am not able to manually set focus by clicking on it.
At first, I thought it was a CSS-issue, which doesn't seem to be the case.
It receives click-events, so I did this:
//iOS-Hack for focusing contenteditable-DIV
$('#textbox').on('click',function(){
if(/iP[ha]/i.exec(navigator.userAgent)){
$('#textbox').focus();
placeCaretAtEnd($('#textbox').get(0));
}
});
where "placeCaretAtEnd" is my own solution to - you may have guessed it ;)
- place the caret at end.
It works like this, but I don't get it why this is necessary.
I'd appreciate any input!

No comments:

Post a Comment