views:

105

answers:

1

So I have dynamically generated content from a MySQL database and I pull it with php. To show what I mean look this example.

Goto http://minecraftadmins.net/browse/ See Skin Preview? I want to make it so when you click it, it opens a jQuery popup with content generated from an external source (AJAX). I know how to make a popup. But it doesnt work when dynamic.

Any ideas?

+1  A: 

You could do something like:

<script type="text/javascript">
$(document).ready(function(){
    $('#skin-preview-421').click(function() {
        $.post($('#skin-preview-421').attr('href'), function(resp){
            $("#dlg-skin-preview").html(resp).dialog('open');
        }, 'html');
        return false;
    });
}); 
</script>

<a id="skin-preview-421" class="ex2trigger" href="get_skin_preview.php?id=421">Skin Preview</a>

<div id="dlg-skin-preview" style="display:none;"></div>

Later you could optimize by assigning the clicks in a loop.

webbiedave