Skip to content

Instantly share code, notes, and snippets.

@KarthikaRamachandran
Last active November 14, 2016 14:24
Show Gist options
  • Select an option

  • Save KarthikaRamachandran/2fb5feaaee5691ed7768c8bf8f124be5 to your computer and use it in GitHub Desktop.

Select an option

Save KarthikaRamachandran/2fb5feaaee5691ed7768c8bf8f124be5 to your computer and use it in GitHub Desktop.
scrollTo
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
queryParams : ['optionName'],
optionName : null,
actions : {
scrollToSecondDiv : function(id){
var scrollTop = $("#"+id).offset().top;
$("body").scrollTop(scrollTop);
this.set("optionName","disabled");
}
}
});
<h1>Scroll To</h1>
{{#link-to "index" (query-params optionName="asc")}}Sort{{/link-to}}
<button {{action "scrollToSecondDiv" "secondDiv"}}>
Scroll Down
</button>
<br>
<br>
{{outlet}}
<br>
<br>
<div id="firstDiv" style="height:300px;width:550px;border:1px solid black;">
<p> Content of the div</p>
</div>
<br/>
<div id="secondDiv" style="height:300px;width:550px;border:1px solid black;">
<p> Content of the div</p>
</div>
{
"version": "0.10.6",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.9.0",
"ember-data": "2.9.0",
"ember-template-compiler": "2.9.0",
"ember-testing": "2.9.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment