Skip to content

Instantly share code, notes, and snippets.

@lambder
Forked from joecorcoran/gist:128728
Created October 15, 2010 21:13
Show Gist options
  • Save lambder/628960 to your computer and use it in GitHub Desktop.
Save lambder/628960 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