Skip to content

Instantly share code, notes, and snippets.

@wnstn
Created August 9, 2012 19:22
Show Gist options
  • Save wnstn/3307311 to your computer and use it in GitHub Desktop.
Save wnstn/3307311 to your computer and use it in GitHub Desktop.
finding pjax
$ ->
$('.subnav a').on 'click', (event) ->
event.preventDefault()
# Find the section of the page to load the new content
currentSection = '#' + $(this).closest('section').attr('id')
# Find the div that pjax should replace
changeContent = '#' + $(currentSection + ' .pjax-content').attr('id')
#fetch the new content and animate it in
page = $(this).attr('href')
$.pjax({
url: page,
container: changeContent
})
animateOut = changeContent + ' .animate-out'
animateIn = changeContent + ' .animate-in'
$(changeContent).on('pjax:beforeSend', ->
Animate.fadeOutRight(animateOut)
$(changeContent).spin()
)
$(changeContent).on('pjax:end', ->
$(changeContent).spin(false)
Animate.fadeIn(animateIn)
)
previousNavElement = $(this).closest('li').index()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment