How to add click functions to Dialog html elements?
This is probably (hopefully) something simple like a scoping/referencing issue.
The 1st time my Dialog opens, it all works beautifully.
But if I open it again, then any click() functions on HTML elements displayed in the Dialog stop working. everything else still works - just those functions don't get called.
- $dialog.html('<p><span id="previmg" title="Previous Image">«</span><span id="nextimg" title="Next Image">»</span><br /><img id="remoteimg" src="' + data.images[0] + '" alt="" />');
$('#previmg').click(function()
{
viewimg('prev', data.images);
});
$('#nextimg').click(function()
{
viewimg('next', data.images);
});
The code above works perfectly the 1st time.
I've also tried writing the function call inline like "<span id="previmg" onclick="viewimg(\'prev\')"> but that didn't work either (although inline alerts() did work).
I even tried standard getElementbyId("previmg"). The elment is found but it wont call any other code.
Any ideas?
Thanks.
EDIT
OK I got my custom buttons to work every time by implementing them as Dialog buttons. However this is not ideal as I dont have any control over those buttons (the alignment is not very usable).
Also I want to understand what the problem was :)