New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Comments

Projects
None yet
2 participants
@bonti

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

This comment has been minimized.

Show comment
Hide comment
@jaspermdegroot

jaspermdegroot Aug 16, 2012

Member

@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();
    });
});
Member

jaspermdegroot commented Aug 16, 2012

@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

This comment has been minimized.

Show comment
Hide comment
@bonti

bonti 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 :(

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

This comment has been minimized.

Show comment
Hide comment
@jaspermdegroot

jaspermdegroot Oct 23, 2012

Member

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

Member

jaspermdegroot commented Oct 23, 2012

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment