Table Cell display popup OnClick with data from xml



I am making a TV Guide, When the Title is clicked on the cell I want a popup to show up with the description of the Title, however I can only make all of the descriptions show up and not just the single one that matches the Title, how would I go about doing this?


HTML



<table id="chart">
<thead><th>Start</th><th>End</th><th>Title</th></thead><tbody><tr><td></td></tr></tbody>
</table>


jQuery



$.ajax({
url: "xml/tvguide.xml" ,
dataType: "xml" ,
type: "GET",
success: function(data) {
$(data).find('tvguide channel[id="bbconemonday"] programme').each(function() {
var title = $(this).find('title').text();
var desc = $(this).find('desc').text();
var start = $(this).find('start').text();
var end = $(this).find('end').text();
$('<tr></tr>').html('<td>'+start+'</td><td>'+end+'</td><td title="'+desc+'">'+title+'</td>').appendTo('#chart');
$("#chart td").click(function(){
alert(desc);

});
});


XML SAMPLE



<tvguide>
<channel id="bbconemonday">
<programme>
<desc>
The latest news, sport, business and weather from the BBC's Breakfast team. Also in HD. [S] Including regional news at 25 and 55 minutes past each hour.
</desc>
<title>Breakfast</title>
<end>0915</end>
<start>0600</start>
</programme>
</channel>
</tvguide>

No comments:

Post a Comment