Multiple jquery buttons on same page behaving oddly
<p>I am trying to place a jquery modal popup button against each row in a table meaning there could be up to 25 buttons on a page - each button needs to popup a dialog containing different content pulled from a database based on the id of the row.</p>

<p>I can get the button to work and display the content properly if it is shown once on the page outside the loop but as soon as I put it into the loop it starts behaving very oddly. When I click any of the buttons it displays the popup with the dynamic content inside but clicking exit cycles through the loop and shows all the dynamic content until all the rows have been shown. </p>

<p>For example, if I have 4 rows when I click button one I get a popup with the content for row one but if I click exit it then shows the content for row two and so on until they have all been shown which is obviously not correct.</p>

<p>How can I get it so it only shows the popup once and only shows the corresponding id rather than all of them?</p>

<pre><code>&lt;script&gt;
// increase the default animation speed to exaggerate the effect
$.fx.speeds._default = 100000;
$(function() {
    $( ".jui-dialog" ).dialog({
        autoOpen: false,
    modal: "true"
    });

    $( ".button" ).click(function() {
        $( ".jui-dialog" ).dialog( "open" );
        return false;
    });
});
&lt;/script&gt;


&lt;begin loop&gt;

&lt;button class="button"&gt;Popup&lt;/button&gt;
&lt;div class="jui-dialog"&gt;
    &lt;div class="jui-dialog-inner"&gt;
        &lt;p&gt;&lt;?=$id?&gt;&lt;/p&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;end loop&gt;
</code></pre>
