Skip to content

Instantly share code, notes, and snippets.

@aslam
Forked from joecorcoran/gist:128728
Created September 8, 2010 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aslam/569746 to your computer and use it in GitHub Desktop.
Save aslam/569746 to your computer and use it in GitHub Desktop.
$(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