Hi John,
Thanks for the clarification over event handlers and live/delegate.
Unfortunately I am using document ready, the full code is below. I am using HTML5 to draw circular placeholders behind the prices of my e-commerce store and this means that if one of the canvas elements is not present in the DOM at the time of pageload or refresh, the canvas isn't drawn and the price appearance is all messed up.
I must also mention that it renders ok in most browsers even on croaky old IE 7 but not with Firefox which is a problem. When you refresh the page with FF some of the prices are there and others aren't , looks really unsightly. That tells me that some of the 24 instances of canvas aren't loading quick enough. I am unable to use one big canvas either because every product is in a different table cell and will have varying widths and heights.
I really want to suport HTML5 but it would seem that canvas just doesn't render quick enough if you have multiple instances (inot as many as 24 at any rate)
.
Anyway, maybe I am creating some huge overhead that I don't know of:
Code:
$(document).ready(function(){
$("#content a img, #content_home a img").hover(function() {
$(this).stop()
.animate({opacity: 0.7}, "medium")
}, function() {
$(this).stop()
.animate({opacity: 1}, "medium")
});
function isCanvasSupported(){
var elem = document.createElement('canvas');
return !!(elem.getContext && elem.getContext('2d'));
}
var i = 0;
var c;
var ctx ;
if (isCanvasSupported())
{
$(".price_canvas_replace").hide();
$('.wrap_link').each(function() {
ctx = $(this).find('.html5_price');
var element = ctx.get(0);
ctx=element.getContext("2d");
ctx.beginPath();
ctx.arc(35,35,35,0,Math.PI*2,true);
ctx.closePath();
var grd=ctx.createRadialGradient(35,35,35,0,Math.PI*2,true);
grd.addColorStop(0,"#8ED6FF");
grd.addColorStop(1,"#004CB3");
ctx.fillStyle= grd;
ctx.fill();
i++;
});
}
});
Bookmarks