Quantcast
Viewing all articles
Browse latest Browse all 4839

Adding key-up action handlers in routes

@GerryAdams wrote:

I’m trying to add key-up validation to an {{input}} object like so:

{{input placeholder="Email Address" value=model.email type="email" key-up=(action 'fieldUpdated') class="form-control"}}

but when I load the page I get the error:

Error: Assertion Failed: An action named 'fieldUpdated' was not found in (generated contact controller)

I don’t get the error with my button:

<button {{action "fieldUpdated"}} disabled={{sendMessageDisable}} class="btn btn-block btn-primary">What's happening?</button>

I figure this is because it’s a <button> HTML element whereas I’m using an input component. I wish to use a component so I can double bind my data.

Here is my route:

import Route from '@ember/routing/route';

export default Route.extend({
  model(){
    return this.store.createRecord('contact');
  },

  actions: {
    fieldUpdated(model) {
      debugger; //Triggers on button, but not input
    }
  }
});

How can I have the input component trigger the logic in my route?

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4839

Trending Articles