Some time ago, I solved a problem for someone who wanted his text ad to grow . I executed a function that listens for scroll events and keyup areas and recounts the number of rows. I wanted to use the code in another project, but there is a problem. The text field is not known. To solve this problem, I use live instead of bind , so the future area will also be connected.
Now I find that live is much slower than bind . I created a simplified jsFiddle example . The top textarea behaves the way I want, but the new ones added flicker due to late signaling (I use Chrome).
How to make live as fast as bind ? The problem is that scroll cannot be used with live . Is there a way to enable scroll for live ? Perhaps there is a jQuery event that signals me that a new TextArea has been added, so can I use a binding to add scroll on a newly created element?
I look forward to your ideas.
EDIT: Changed the link to the code. Removed scrollingCode. Added one more button to create another text field. The problem is with scrolling. It does not work.
Clarification: I do not know which function will create the text area. I see flickering dynamically added mailboxes in Chrome .
For future readers:
In jQuery 1.3.x, only the following JavaScript events are used (in addition to custom events) that can be associated with .live (): click, dblclick, keydown, keypress, keyup, mousedown, mousemove, mouseout, mouseover, and mouseup . As jQuery 1.4, the .live () method supports custom events, as well as all JavaScript events that bubble up. Starting with jQuery 1.4.1, it even focuses and blurs the work with the living (matching with a more suitable, bubbling, focusin event and focus). Starting with jQuery 1.4.1, a hover event can be specified (matching to mouse and mouse, which, in turn, are matching to mouseover and MouseOut).
javascript jquery autoresize textarea live
Kees C. Bakker
source share