javascript - Caret position in textarea in IE using jQuery caret plugin -


i'm using plguin caret position of textarea. have <div>, clicking on shows <ul>with smilie list put 1 of them textarea. clicking on <div> fires blur event on textarea. save caret position on blur:

oroot.blur(function() {     caret_pos = $(this).caret(); }); 

and after user click on smilie, put in textarea caret before lost focus:

olist     .delegate('.chat-smile', 'click', function() {         var oroot = $(this).parent().data('oroot');          if (is_default_value(oroot)) oroot.val('');          oroot.val(oroot.caret(caret_pos).caret().replace($(this).attr('smilie-code')));          toggle_list($(this).parent());     }); 

the problem in ie seems plugin doesn't work if textarea has no focus, , in ie blur event handler fired after focus lost.

any ideas of workaround this? thinking of saving caret position on click, keyup, focus ie..

i've tried workaround thought of befor (saving caret position on click, keyup, focus ie). function binds events save caret position looks this:

function bind_save_caret_pos() {     var event_to_bind = $.browser.msie ? 'keyup mouseup' : 'blur';      oroot.bind(event_to_bind, function() {         caret_pos = $(this).caret();     }); } 

keyup deals typing, deleting, moving around text arrows etc.

mouseup deals selecting peace of text, moving cursor etc.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -