I have code like this using jQuery-svg
function replaceRaster(){
$('#png').remove()
a = $('#graphic')
b = a.svg(a)
a.load('IDC_Energy.svg',
{onLoad:bind} )
svg = document.getElementById("graphic").children[0]
console.log(svg)
svg.addEventListener('load', bind)
}
An event handler bindfires before jQuery-svg-dom can select elements in SVG data. My code should look at SVG and assign different classes and attach listeners to different elements, but it cannot find them. If I call bindin the console after loading, it can find all SVG elements.
Am I doing something wrong? Is there any other way to detect when an SVG DOM is available? I thought about using a timer, but it really is hacked, especially considering that my SVG files can be several megabytes in size.
source
share