The code, loads some 'divs' and pops them all in a single dialog object (Sec1).
Each alert has a "dismiss" link(Sec2), with a JQuery event-listener that sends an ajax request, and shows a new dialog, created from the result (Sec3).
Seems like it's all working, but, with one problem: after clicking the 'dissmis', the result dialog is loaded in many (10, currently, in a previous version of the code, only 5..)
//Sec1
$("#alerts_list").dialog({
title : "Alerts",
resizable : false,
dialogClass : "alerts",
modal : true,
maxHeight: $(window).height()- 20,
buttons : [{
text : "Done",
click : function() {
$(this).dialog("close");
}
}]
});
The alerts code is:
HTML
//Sec2
<div class="alert<?php echo " " .$alert_class?>">
<h3>Title</h3>
<p class="alert-message">some text</p>
<div class="toolbar">
<a class="dismiss" href="/alerts/dismiss/1">dismiss</a>
<a href="/alerts/">settings</a>
</div>
</div>
//Sec3
$(".alert .toolbar a.dismiss").on('click',function(eve) {
eve.preventDefault();
$url = $(this).attr("href");
$.get($url, null, function(data) {
$("p").html(data).appendTo('body').dialog();
});
});
<p>elements do you have in your page?$("p")selects all of them.