ember-route-action-helper icon indicating copy to clipboard operation
ember-route-action-helper copied to clipboard

Support `value="target.value"`

Open lolmaus opened this issue 8 years ago • 4 comments

It's not possible to use {{route-action}} with native HTML controls because the helper is unable to extract the value.

E. g.:

<select onchange={{action 'someAction' value="target.value"}}>

This works with a normal action but fails with a route-action.

lolmaus avatar Jun 24 '16 11:06 lolmaus

Heh, "not possible" is relative. You could write your actions to accept the full event and that would work fine...

I do agree that parity with {{action in this way would be nice, though I really hate the name value for what should be valuePath.

rwjblue avatar Jun 24 '16 11:06 rwjblue

@rwjblue

You could write your actions to accept the full event and that would work fine...

Well, when you do {{route-action}}, the action function is not passed any event.

lolmaus avatar Jun 24 '16 22:06 lolmaus

+1 I would like this feature as well. As an example if a component has a select box (native) with onchange event that passes in value="target.value" then I would not need to map actions on the component element and simply calling route-action from component would map to the proper action defined in my route.

Otherwise I need to say something like: {{component actionFromComponent=(route-action 'actionInRoute')}} and in the action itself within a component: <select {{action 'actionInComponent' value='target.value' on='change'}} and have the

actionInComponent() {
  this.sendAction('actionFromComponent');
} 

gogromat avatar Jan 11 '17 18:01 gogromat

Hi All,

Is there any solution to this issue? I am trying to use route-action helper for checkbox as follows: <input type="checkbox" onchange={{route-action "selectAllTables" value="target.checked" }}>Select All

It calls my action inside route, but it is passing some event object instead of checked value (I am expecting true/false) like it does for the usual action helper:

I am also facing the same issue while using select drodown: <select class="col-sm-8" onchange={{route-action "setSelection" value="target.value"}}>

Here I am expecting to get the values JDBC or HDFS when the actions is fired.

If it can be done by writing action to receive full event, please give some example how to extract required information from the event.

I am new to ember. Please help.

gssonal avatar May 21 '18 10:05 gssonal