Reputation: 29
Within the Discover Meteor Book project called Microscope. How do you enable the cursor when a user clicks on the "Submit Post" or the "Discuss" button? Currently, after a user clicks on the "Submit Post" or "Discuss" button, the user has to use a mouse to click in the field to move the cursor there in order to type.
Upvotes: 2
Views: 51
Reputation: 22696
You can use templates onRendered
lifecycle event along with standard jQuery objects focus
method.
Suppose your template is named postSubmit
, then add this code to make the first input (or textarea, or whatever...) grab focus.
Template.postSubmit.onRendered(function(){
this.$("input:first, textarea:first, select:first").focus();
});
Upvotes: 1