jquery
を使用して特定のセクションにスクロールします。
$('html,body').animate({
scrollTop: $("a[name='someAnchor']").offset().top
});
this SO answerを参照してください。
ビューがレンダリングされた後にアンカーにスクロールするには、ルートのビューの定義内のdidInsertElement
をオーバーライドします。
this SO answerを参照してください。ここで
App.LonglistView = Ember.View.extend({
didInsertElement: function() {
// Place the scroll to anchor code here.
$('html,body').animate({
scrollTop: $("a[name='someAnchor']").offset().top
});
}
});
はjsfiddleでa working example(私は明確にするための任意のデータモデルを追加していない)である
EDIT:あなたはまた、スクロール
document.getElementsByTagName('a')[name='someAnchor'].scrollIntoView()
jsfiddle exampleを行うには非jqueryの方法を使用することができます同様に。
どのような[URLの種類](http://emberjs.com/guides/routing/specifying-the-location-api/)を使用していますか?デフォルトでEmberはアンカーと衝突するハッシュ(#)を使用します。技術的には、[hashbang(#!)](http://stackoverflow.com/questions/14929170/hashbang-urls-using-ember-js)のクライアントURLを実装すると、scrollspy(または同様のもの)を使用できます。 – MilkyWayJoe
@MilkyWayJoe Emberのデフォルトのハッシュベースのナビゲーションを使用しています。私はちょうど履歴ベースのナビゲーションを試してみましたが、上記の私のアプリケーションと私のjsFiddleの両方では機能しませんでした(Exception "' URLに一致するルートがありません/ _display/'")...ありがとう私が今調査するscrollspyとhashbangの提案。 – Abdull
[Ember.js anchor link]の複製が可能です(http://stackoverflow.com/questions/18445661/ember-js-anchor-link) – givanse