-
-
Save lambder/628960 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
//run the accordion plugin, set height of sections to height of content | |
$("#accordion").accordion({ autoHeight: false }); | |
}); | |
;(function($) { | |
//write new sammy application | |
var app = new Sammy.Application(function() { | |
with(this) { | |
//corresponds to routes such as #/section/1 | |
get('#/section/:section_id', function() { with(this) { | |
$(function() { | |
//accorion 'activate' opens the section which corresponds to the id in the url | |
//-1 as the accordion is zero-based | |
$("#accordion").accordion('activate', params['section_id']-1); | |
}); | |
}}); | |
} | |
}); | |
$(function() { | |
//run the Sammy app you wrote above | |
app.run() | |
}); | |
})(jQuery); | |
//kind of hacky but needed since the accordion plugin overrides href attributes | |
function changeHash(i) { | |
window.location.hash = "/section/"+i; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment