Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the Ember.js events for TextField Class

Tags:

ember.js

Just started to play with Ember.js and by reading the code I encounter the following lines:

Em.TextField.extend({
    insertNewline: function() {
        ....
    }
});

as far as I understood, insertNewLine is an event on clicking "enter" while inside the field, but looking in the documentation for TextField I failed to find information about this event, and other events of TextField as well.

What events are supported?

like image 916
Salvador Dali Avatar asked Nov 08 '12 14:11

Salvador Dali


People also ask

How does Ember js work?

Ember. js uses Handlebars, a lightweight templating engine also maintained by the Ember team. It has the usual templating logic, like if and else , loops and formatting helpers , that kind of stuff. Templates may be precompiled (if you want to cleanly organize them as separate .

What is Ember js good for?

Ember. js is an open source, free JavaScript client-side framework used for developing web applications. It allows building client side JavaScript applications by providing a complete solution which contains data management and an application flow.


2 Answers

Not a noob question at all!

Ember TextField inherits from Ember's TextSupport. TextSupport is basically a class that can share functionality for text fields (inputs) and text areas.

If you take a look at TextSupport (https://github.com/emberjs/ember.js/blob/master/packages/ember-handlebars/lib/controls/text_support.js) you'll see a key map at the bottom of the file. This map will be queried on every key up event, trying to match a key to a function. The two default functions are insertNewline (enter) and cancel (esc). You can add as many as you want here.

like image 197
Ryan Avatar answered Oct 06 '22 00:10

Ryan


The keyUp and focusOut methods are also really helpful. I use them a lot for data validation type purposes on edit forms.

https://github.com/emberjs/website/pull/30

like image 26
WallMobile Avatar answered Oct 05 '22 23:10

WallMobile