Dom
Dom

Reputation: 404

Change event for textarea in ember

So i have this textarea

{{textarea value=model.description key-press="upload" required=true rows="5" aria-describedby=describedby}}

as you can see above the keypress event works just fine i.e it is able to trigger the upload action

Now when i replace key-press with change or onchange the upload action dose not get fired. Here is the code

{{textarea value=model.description onchange="upload" required=true rows="5" aria-describedby=describedby}}

How to call change event action in ember for textarea??

Upvotes: 4

Views: 3733

Answers (2)

Ember Freak
Ember Freak

Reputation: 12872

TextArea is extending TextSupport so here are the events supported by inbuilt,

+--------------------+----------------+
|                    |                |
| event              | attribute name |
+--------------------+----------------+
| new line inserted  | insert-newline |
|                    |                |
| enter key pressed  | insert-newline |
|                    |                |
| cancel key pressed | escape-press   |
|                    |                |
| focusin            | focus-in       |
|                    |                |
| focusout           | focus-out      |
|                    |                |
| keypress           | key-press      |
|                    |                |
| keyup              | key-up         |
|                    |                |
| keydown            | key-down       |
+--------------------+----------------+

If you want to trigger action for onchange then you can try below options,

  1. Instead of {{textarea you can use normal <text-area like the below

    <textarea value={{appName}} onchange={{action 'onTextFiledChange'}} />

  2. onchange event also triggering upon the focus-out for text-area,

    {{textarea value=appName focus-out='onTextFiledChange' }}

  3. You can create your own component by extending the TextArea

    {{my-textarea value=appName onTextFiledChange='onTextFiledChange'}}

Have a look at this twiddle

Upvotes: 2

Sedad Kosovac
Sedad Kosovac

Reputation: 668

You can do it like this ember has some problems with events on input helpers.

 <textarea value={{model.description}} onchange={{action "upload" value="target.value"}} >

Upvotes: 1

Related Questions