문제

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,
    });
});
도움이 되었습니까?

해결책

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"));
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top