Created
September 14, 2012 19:12
-
-
Save rlemon/3724054 to your computer and use it in GitHub Desktop.
Load content via jQuery.load
This file contains hidden or 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() { | |
| var links = $("a[data-ajax]"), | |
| spinner = $('<img src="assets/img/295.gif" />'); | |
| links.each(function(i, element) { | |
| $(element).on('click', function() { | |
| var content = $('#content'), | |
| href = this.href, | |
| $this = $(this); | |
| spinner.css({ | |
| position: 'absolute', | |
| top: (content.height() / 2) - 32 + 'px', | |
| left: content.position().left + (content.width() / 2) - 32 + 'px' | |
| }); | |
| content.css({ | |
| opacity: '0.5' | |
| }); | |
| content.parent().append(spinner); | |
| content.load(href + ' #content', function() { | |
| content.css({ | |
| opacity: '1' | |
| }); | |
| spinner.detach(); | |
| $('li.active').removeClass('active'); | |
| $this.parent().addClass('active'); | |
| var dropdowns = $this.parents('li.dropdown'); | |
| if (dropdowns.length > 0) { | |
| dropdowns.addClass('active'); | |
| } | |
| $('li.dropdown').removeClass('open'); | |
| }); | |
| return false; | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment