简体   繁体   中英

Ember.js autofocus on just created template

Is it possible in Ember to set focus on just created template?

  <script type="text/x-handlebars" data-template-name="foo">
    {{#linkTo "foo.bars" class="success radius button"}}GET ALL THE BARS{{/linkTo}}
    {{outlet}}
  </script>

How to set focus on the new foo/bars template?

Have you tried scrollIntoView ? You can create a view that calls that on its element after rendering:

App.FooFoo = Ember.View.extend({
  templateName: 'foo',

  didInsertElement: function() {
    var el = this.$()[0];
    el.scrollIntoView();
  }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM