how to resize text area
Added by Vigeous List over 14 years ago
Hello,
I am trying to resize the text area in the app/views/wiki/edit.rhtml file.
this line:
<%= f.text_area_tag :reason, :nil :size =>'5x15', :class => 'wiki-edit', :accesskey => accesskey(:edit) %>
What I am tryint to get is that, if I enter only one line, the rows of the text area should be 1, and if I enter 10 (or n rows) lines of text, the text area should grow (every second) to 10 (or n rows) rows.
Similar solution is used in trac with jQuery:
<script type="text/javascript">
jQuery(document).ready(function($) {
$("#text").blur(function() {
$("#scroll_bar_pos").val(this.scrollTop);
}).get(0).scrollTop = $("#scroll_bar_pos").val();
$("#editrows").change(function() {
resizeTextArea("text", this.options[this.selectedIndex].value);
});
function autoResizeText() {
var preview_height = $("#preview").height();
if (preview_height)
$("#text").height(preview_height);
}
autoResizeText();
$(window).resize(autoResizeText);
$("#text").autoPreview("/trac/ecom/wiki_render", {
realm: "wiki", id: "Shops"
}, function(textarea, text, rendered) {
$("#preview div.wikipage").html(rendered);
autoResizeText();
});
});
</script>
Could someone help me to adapt the script to my text area, please?
Thank you,
Vige
Replies (1)
RE: how to resize text area
-
Added by Felix Schäfer over 14 years ago
Redmine uses prototype, not jquery, so you'd have to look for something similar for prototype.