qarthandso
qarthandso

Reputation: 2190

Simple Ember.js Input Syntax

I'm seeing conflicting within the ember guides on how to go about actions syntax on an {{input}} helper. I'm referring to the key-press and key-up parameters.

This section shows it without parenthesis as such:

{{input value=firstName key-press="updateFirstName"}}

Yet here (with the code snippet titled "app/templates/components/list-filter.hbs"), it does use parenthesis as such:

{{input value=value key-up=(action 'handleFilterEntry') class="light" placeholder="Filter By City"}}


I'm not sure why the API docs leave out the parenthesis but the example puts them in. Any insight appreciated

Upvotes: 2

Views: 110

Answers (1)

Ember Freak
Ember Freak

Reputation: 12872

When you use the below format key-up=(action 'handleFilterEntry') , then handleFilterEntry function will be called with the following argument value,jQueryEvent.

Likewise,

key-up='handleFilterEntry' ==> value, jQueryEvent

keyUp=(action 'handleFilterEntry') ==> Only jQueryEvent

keyUp='handleFilterEntry' ==> Wont trigger the event - this is wrong. Its like normal event, so you need to provide function not the string.

When Event-Name is dasherized, inside input helper you will get first argument the value and then jQuery event. if its not dasherized then its normal thing so you will get jQuery Event arguments alone.

Sample twiddle which demonstrate this behavior.

Upvotes: 1

Related Questions