简体   繁体   English

Ember.js自动关注刚刚创建的模板

[英]Ember.js autofocus on just created template

Is it possible in Ember to set focus on just created template? 在Ember中是否可以将重点放在刚创建的模板上?

  <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? 如何将重点放在新的foo/bars模板上?

Have you tried scrollIntoView ? 您是否尝试过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();
  }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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