开发者

Mobile Safari Not allowing typing in Textarea when Jquery Focus event is triggered?

I've been having an issue with textboxes in Mobile Safari. When this function is included:

$("#text_comment").live('foc开发者_运维问答us', function () {
    $(this).css('height','50px');
});

$("#text_comment").live('focusout', function () {
    $(this).css('height','23px');
});

The function resizes the textbox on focus, but you can no longer type in the textbox. On the iPhone you can click the letters on the keyboard but nothing shows up.

I think it has to do with the event interfering with mobile safari's ability to insert characters into the textarea, but it is very annoying.

Does anyone have a fix, or can a second focus event be triggered to allow the text to show up?


So here is my solution to my own question:

$('#text_comment, searchinput, timestamp').live('keypress', function(event) {

      var txt = $('#spn').text();
      var pressed = (txt + String.fromCharCode(event.keyCode));

    var el = this;

    setTimeout(function() {
         var string = $(el).val(); 
         if(string.length < 1) {
            $(el).val(pressed);
         }
    }, 100);

});

It should work for anyone having this issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜