Skip to content

Instantly share code, notes, and snippets.

@joecorcoran
Created June 12, 2009 16:04
Show Gist options
  • Save joecorcoran/128728 to your computer and use it in GitHub Desktop.
Save joecorcoran/128728 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