PDA

View Full Version : [SOLVED] Make all existing Textareas in a form growable



shanebush
31 May 2007, 7:40 AM
I have x number of existing textareas on a page. I want to make all of them growable without knowing the exact id.

The problem is that the methodology I'm using doesn't work right. It only sets the *last* textarea to be growable. When I look at the dom, each TextArea's className was updated with "x-form-textarea x-form-field", just like it's supposed to. It's just that the grow "event" doesn't work for any but the last textarea.

Here's an example of what I've tried:


<!doctype html public "-//w3c//dtd html 4.01//en" "http://www.w3.org/tr/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="../Ext/resources/css/ext-all.css">
<script type="text/javascript" src="../Ext/adapter/yui/yui-utilities.js"></script>
<script type="text/javascript" src="../Ext/adapter/yui/ext-yui-adapter.js"></script>
<script type="text/javascript" src="../Ext/ext-all.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
//set all textareas to be "growable" ... i hope.
Ext.select("FORM TEXTAREA").each(function(element){
var grow = new Ext.form.TextArea({
width:400, grow:true
});
grow.applyTo(element);
});
});
</script>
<style>
TEXTAREA{overflow:hidden;}
</style>
</head>
<body>
<form method="post" action="CreateFCCase.asp">
<textarea name="Description of Work Required" id="moddescriptionofworkrequired" cols="80" rows="3" class=""></textarea>
<br/>
<textarea name="Any Additional Information" id="addanyadditionalinformation" cols="80" rows="3" class=""></textarea>
</form>
</body>
</html>


Now, I'm probably either approaching this the wrong way, or trying to do something that wasn't intended with Ext. But I figure it should be possible to quickly apply a base set of functionality to a "set" of form fields at once.

Any thoughts?

I did a pretty good scouring of the forums for any previous mention of this type of thing, but couldn't find anything. If there's a thread that covers this already, my apologies.

tryanDLS
31 May 2007, 8:49 AM
This might be b/c you're creating flyweight objects rather than real objects in the select. Try passing true as the 2nd arg.

shanebush
31 May 2007, 9:18 AM
That got it! Looks like I've got some reading to do on flyweight objects vs "real".

Thanks for the quick response!

Shane