I have a very simple Windows Gadget that I am trying to convert to JQuery. This is being done to both reduce code and help me get familiar with JQuery, which is new to me.
It consists basically of a table that, when you click in a cell fills the cell with an X. This is working fine in JavaScript but I'd like to get it to work in JQuery. There is also a button that will clear all cells.
I've got it all working when I open the gadget HTML in a browser but when I run the windows gadget the $("td").click event isn't detected.
This is a simplified example that demonstrates the problem. In the browser, clicking a td puts an 'X" in the cell and clicking the button will clear the entire table but in the gadget engine the td event never fires.
Any ideas why?
Thank you.
$(document).ready(function()
{
$("td").click(function()
{
$(this).text("X");
});
$("button").click(function()
{
$("td").text("");
});
});
Editing to add: To elaborate, the td.click event never fires but it will catch a bubble up event. In other words, I have added a transparent image, the same size as the table cell, in each cell. When the IMG is clicked, the event will bubble up and fire the td.click event.
This has been a satisfactory work-around but I would still like to know why td.click fails completely in the windows-gadget engine and if there is any resolution.
In case anyone else comes across this, here is the workaround that I ended up going with:
$('td').html('<img src="./images/Blank.png" />');
Where Blank.png is a completely transparent image the same size as the td. No actual code is associated with it but when you click it, the event bubbles up to the table cell and everything works as it should.