I am having trouble getting my modal window function to bind to some returned data. I am using Cody Lindy's Jquery.DomWindow plugin. Please note that everything functions properly, except for this problem.
The problem occurs when the data that is returned from my jQuery.getJSON call contains a link that is supposed to open up the modal window. The link however, is not recognised by the DOM and therefore is not bound by any function.
My jQuery function is:
$(".deleteThis").live("click", function(){
var $this = $(this);
$.getJSON(this.href, function(data) {
if( data.success == '1') {
$this.parent().html('<span style="background:#f1ffd6;padding:5px;">' +data.msg+'</span>');
}
else if( data.success == '2') {
$this.parent().html('<span style="background:#f1ffd6;padding:5px;">' +data.msg+'</span>');
}
else {alert("Failure (most likely our fault).");}
});
return false;
});
The php script that jQuery sends to contains some database scripting (not shown below as it is not relevant). The relevant php code that returns the JSON array is this:
if($del ==1 ){
$msg= "$name has been deleted. (<a href='media/delete_coll.php?cid=$cid&delete=0' class='deleteThis' >undo</a>)";
print json_encode(array("success" => 1,"msg" => $msg));
}
if($del ==0 ){
$msg= "$name <a href='media/editCollab.php?coll=$coll_id' class='absoluteIframeDOMWindow'>edit</a>
<a href='media/delete_coll.php?cid=$coll_id&delete=1&coll=$coll' class='deleteThis' > delete</a> |
Collaborator has restored.";
print json_encode(array("success" => 2, "msg" => $msg));
}