I\'m looking for an event that tells me when a surface has been rendered so I can call methods like surface.focus().
If I call focus immediately after I create the s
I marked johntraver's response as the answer, but I also wanted to include a complete working example for the InputSurface for people like me just learning famous. This code subclasses InputSurface so that the focus method will work.
Once the InputSurface is rendered it gains focus.
TextBox.js
define(function(require, exports, module) {
var InputSurface = require('famous/surfaces/InputSurface');
var EventHandler = require('famous/core/EventHandler');
function TextBox(options) {
InputSurface.apply(this, arguments);
this._superDeploy = InputSurface.prototype.deploy;
}
TextBox.prototype = Object.create(InputSurface.prototype);
TextBox.prototype.constructor = TextBox;
TextBox.prototype.deploy = function deploy(target) {
this.eventHandler.trigger('surface-has-rendered', this);
this._superDeploy(target);
};
module.exports = TextBox;
});
implementation
this.email = new TextBox({
size: [300, 40],
placeholder:'email'
});
var event_handler = new EventHandler();
event_handler.on('surface-has-rendered', function(control){
control.focus();
});
this.email.pipe(event_handler);