Hi guys,

I have the following code which is drawing a canvas on each element on the page but it is in a CMS and the elements are being added dynamically which means that the element is not always there when JQuery parses the DOM. My error says "ctx is not defined" but it does render some of the canvas elements so I know it is defined at some points.

I know I am supposed to use live() or delegate but I have only done it with click handlers before and I'm not sure of the exact syntax in this instance. Can anyone help me?

Code:
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++;

   
});
}