问题描述:

I'm using Elastic with a textarea that's loaded within a hidden container. When it's displayed, entering text causes it to grow each time I add a character. I think it has to do with the hidden textarea having no width defined. I tried adding a call to setTwinWidth() within the update() function. It worked, but IE7 & IE8 started throwing "stack overflow" and "out of memory" errors. Then I realized that with my change, both functions were now calling each other over and over.

Any idea why setTwinWidth() needs to call update()?

Any clues on how to fix the plug-in (see fiddle below)?

Hidden Elastic Test - jsFiddle

Following code is from jsFiddle. Stackoverflow wouldn't let me submit the question with the jsFiddle but without some code (seems weird). It's not really relevant

$(document).ready(function() {

$('textarea').elastic();

$('button').click(function() {

$('#rowHidden').toggle();

});

});

I've tried contacting the author but heard nothing back.

网友答案:

Why don't you just hide the textarea after things have been initialized instead of via the css like this - http://jsfiddle.net/svXEL/5/ ? That seems to function correctly.

$(document).ready(function() {   
    $('textarea').elastic();

    $('button').click(function() {
       $('#rowHidden').toggle(); 
    });    

    $('#rowHidden').hide();
});
相关阅读:
Top