View difference between Paste ID: 6ebx5mXG and TzufZMJg
SHOW: | | - or go back to the newest paste.
1
<a class="ajax" rel="showGallery" href="photo/gallery/1">Gallery 1</a>
2
<a class="ajax" rel="showGallery" href="photo/gallery/2">Gallery 2</a>
3
4
<script>
5
	$( function() {
6
		$( 'a.ajax' ).live( 'click', function() {
7
			var href = $( this ).attr( 'href' );
8
			var drawFunc = $( this ).attr( 'rel' );
9
			
10-
			$.get(
10+
			var data = getFromCache( 'some_key' );
11-
				href,
11+
12-
				{},
12+
			if ( data ) {
13-
				function( data ) {
13+
				draw( drawFunc, data );
14-
					draw( drawFunc, data );
14+
				// Save in stack
15-
					// Save in stack
15+
			} else {
16-
				},
16+
				$.get(
17-
				'json'
17+
					href,
18-
			);
18+
					{},
19
					function( data ) {
20
						draw( drawFunc, data );
21
						// Save in stack
22
					},
23
					'json'
24
				);
25
			}
26
			
27
			return false;
28
		});
29
	});
30
	
31
	function draw( drawFunc, data )
32
	{
33
		// Spec effects
34
		drawFunc( data );
35
		// Spec effects
36
	}
37
	
38
	function showGallery( data )
39
	{
40
		// Draw gallery
41
	}
42
</script>