Subscribe :: Bookmark and Share

Random ravings from

sponsors

eBay Auctions

IBM X220 EServer PIII 1.2 GHz/512 mb Server   IBM X220 EServer PIII 1.2 GHz/512 mb Server
USD$95.00 Bids: 0
Location: US
General Technics PIII 1.2 Ghz Blade Server 512MB 20G   General Technics PIII 1.2 Ghz Blade Server 512MB 20G
USD$9.00 Bids: 0
Location: US
HP DL380 G5 DUAL CORE 1.6 GHz 4GB 4x 72GB SAS Server 2U   HP DL380 G5 DUAL CORE 1.6 GHz 4GB 4x 72GB SAS Server 2U
USD$2,995.00 Bids: 0
Location: US
Tyan Server S2882-D Dual AMD Opteron 248 2.20 GHz, 8GB   Tyan Server S2882-D Dual AMD Opteron 248 2.20 GHz, 8GB
USD$750.00 Bids: 0
Location: US
Sun Fire V210 Server w/  2 x 1.34 GHz / 4Gb / 2 x 73GB   Sun Fire V210 Server w/ 2 x 1.34 GHz / 4Gb / 2 x 73GB
USD$3,400.00 Bids: 0
Location: US

21 April 2008

Hacking Snap to play nice with AJAX

Comments (0)

Snap have a very nice site preview feature. You can see it in action on this site with the little bubbles beside each link. It's not always up to date, but when it works, its great.

One slight problem, the javascript client is just not that bright. It's not AJAX aware, & if you update part of page, then the Snap script just ignores it: boo.

I've found a very simple way around this. Every time you replace a div via AJAX, make sure you run this script after the div has finished loading. This will tag the new url's with snap.

<script type="text/javascript">
  SNAP_COM.shot_main_js_called = false;
  SNAP_COM.shot_main_js();
</script>

The first command fools the snap script into thinking that is has not been run before, whilst the second calls the same function that's called on the window.onload event.

It really is a brain dead simple hack & I find it bit weird that this not a supported feature.

Leave a comment
Name (required)
 
Mail (will not be published)(required)
 
Website
 

 

Back