Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

On pasting to a textarea, no auto grow occurs until one taps into and starts editing #4854

Closed
bonti opened this issue Aug 16, 2012 · 3 comments
Assignees
Milestone

Comments

@bonti
Copy link

bonti commented Aug 16, 2012

Apologies in advance if this issue has been logged already or if it is not an issue, however if it is not I would like to know if there is a work around, business expects that on pasting a large text, the textarea control should auto grow. We have tested this out on the jquery mobile website from the iPad/iPhone/Android and see the same issue. One workaround I thought of was to access the click/tap event and force it to auto grow. How would one do that?

@jaspermdegroot
Copy link
Contributor

@bonti

Forcing the textarea to auto grow can be done with $( "textarea" ).keyup();.
The problem might be finding the right event to bind to, because I suppose you want the textarea to grow as soon as paste is clicked in the contextmenu. I don't think the "paste" event is supported on iOS and the "change" event most probably only fires after the textarea loses focus. Maybe "input" works. Here is some code you can test with:

$( document ).on( "pageinit", function(){
    $( document ).on( "input paste change", "#mytextarea", function() {
        $( this ).keyup();
    });
});

@bonti
Copy link
Author

bonti commented Aug 17, 2012

Thank you, uGoMobi, unfortunately, that code broke the textarea autogrow, I included it in a simple script tag at the top of the page like so, I only replace dt he #mytextarea to a class I associated with the textareas on my page (my page is dynamically generated on pageshow)

$( document ).on( "pageinit", function(){
$( document ).on( "input paste change", ".testTextarea", function() {
$( this ).keyup();
});
});

I next tried it in my pageshow event, like so, but still no luck

// Handle the "page show" of the current page
$('#surveyPage').live('pageshow',
function () {
// jason call + knockout code
$(#surveyPage).on("input paste change", ".testTextarea", function () {
$(this).keyup();
});
});

I get an exception saying that the object has no "on" defined , so I am afraid, I have had no luck :(

@ghost ghost assigned jaspermdegroot Sep 24, 2012
@jaspermdegroot
Copy link
Contributor

We have to test this again after/if we land the suggested fix for #2834

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants