[jQuery] Tooltip read xml file
Hello.
I am a newbie with jquery and I need and little help.
I am creating bassistance jQuery tooltip plugin.
The problem is that I can not get certain parts of an XML document and
insert it into the tooltip.
The first time I pass the cursor, nothing happens. After the
information is not updated.
The example application can be viewed at: http://in.hostei.com/bass/index.html
My jQuery code is:
$('div.cont span').tooltip({
track: true,
delay: 0,
showURL: false,
fixPNG: true,
top: 0,
left: 15,
fade: 250,
bodyHandler: function() {
$(this).css('cursor', 'help');
concept = $(this).attr('id');
$.get("data.xml", function (xml) {
$(xml).find('ter').each(function() {
ref = $(this).attr('ref');
if (ref == concept) {
nom = $(this).find('nom').text();
d1 = $(this).find('d1').text();
d2 = $(this).find('d2').text();
imagen = $(this).find('imagen').text();
}
});//each
});//get
return $('<h3>' + nom + '</h3><img src="' + imagen +
'"/>' + d1 + '
' + d2 + '
');
},//bodyHandler
});//tooltip
});//document.ready
My xml code is:
<ters>
<ter ref="mancha" letra="a">
<nom>La Mancha</nom>
<d1>La Mancha es una región natural del centro de.......</
d1>
<d2></d2>
<imagen>im/lamancha.png</imagen>
</ter>
<ter ref="hidalgo">
<nom>Hidalgo:</nom>
<d1>El concepto de hidalgo proviene de España y es .......</
d1>
<d2></d2>
<imagen>im/hidalgo.png</imagen>
</ter>
</ters>
Thank you very much and sorry for my bad English.