Use a delegate event handler on the dialog div that traps clicks on links:
$("#dialog").on("click", "a", function(e) {
e.preventDefault();
$("#dialog").load($(this).attr("href"));
});
Question
I'm having some problems with Jquery Dialog Box and links inside. I want to open a dialog which loads a child template with a list of objects. What Im trying to do next is making links of this objects and when you click them they load in the same dialog. How should i do this? Can i mark the links with an ID and somehow start a function on a click? Or whats the best way?
$("#mylist").click(function(event) {
event.preventDefault();
$('#dialog').load($(this).attr('href')).dialog({
width: 800,
height: 530,
resizable: false,
title: "Dialog Title",
autoOpen: true,
});
});
Solution
Use a delegate event handler on the dialog div that traps clicks on links:
$("#dialog").on("click", "a", function(e) {
e.preventDefault();
$("#dialog").load($(this).attr("href"));
});