If you want to create a smooth jump effect using JavaScript and jQuery, you can easily do it yourself. Start by assigning an ID to the element you want to jump to in your HTML code. For example, let's use jump-to-me
:
<h1 id="jump-to-me">Testing</h1>
Next, give the links that will trigger the jump an ID or class for easy filtering. In this instance, we'll use the class toJump
:
<a href="#this-doesnt-matter" class="toJump">Jump to the H1</a>
Finally, add some JavaScript code to handle the jumping functionality. You can place this code anywhere within your Backbone application, such as in the events hash of the parent view. In the following example, we'll enclose it within a jQuery DOM ready wrapper:
$(function() {
$("a.toJump").click(function(event) {
event.preventDefault();
$(window).scrollTop($("#jump-to-me").offset().top);
});
});