Search code examples
jquerytextareaword-wrapresizablejquery-ui-resizable

Issue with textarea resize and text wrap when textarea field is inside a table


There are many posts on how to disable textarea resizing. I have a reverse problem. In fact two. I need to enable it. It is inside a table td. Here is the simple markup. It is generated dynamically, but thats besides the point (or so I think). Other problem is with textwrap.

<form>
  <table>
    <tbody>
      <tr>
        <td colspan="2" class="description_input">
          <input class="descr_text" type="textarea" name="descr_1">
          <input type="file" name="filename"/>
        </td>
      </tr>
   </tbody>
  </table>
 </form>

If I use JqueryUI resizable() widget, it does not work because the text area is dynamically generated and I suspect there are issues with event binding.

The second problem is that I am unable to get word wrap on the text area, it just keeps accepting the input as one long single-line string. I tried a few CSS on the textarea field. Just realized while writing this post that may be I should set CSS on the outer td too?

Please help!!


Solution

  • change:

    <input class="descr_text" type="textarea" name="descr_1">
    

    to:

    <textarea class="descr_text" name="descr_1"></textarea>
    

    fiddle

    U can resize it using:

    textarea{
        height: some px;
        width: some px;
    }