jquery dialog content issues
<p>Being pretty new to jquery, I've spent several hours trying to open video url links into a dialog. I just cant seem to get it right... either dialog wont show, it will show the same vid regardless which clicked, or it will append to bottom of page. Someone please help?</p>

<p>Ultimately, I'd like to have something more flexible/efficient. I wanted to try and use like a media plugin, but not sure how or which.</p>

<p>I just want to be able to open video and pdf links in dialog and have the dialog resize to content, maybe with a max size...</p>

<p>There is a better way, right?</p>

<p>EDIT: SOLVED </p>

<p>DIV:</p>

<pre><code>&lt;div id="divwrapper"&gt;
&lt;div id="dialog"&gt;&lt;object width="480" height="385"&gt;&lt;param name="movie" value="{VIDURL}"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="{VIDURL}" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>CODE:</p>

<pre><code>$(function(){
    // Dialog           
    $('div#dialog').dialog({
        autoResize:true,
        autoOpen: false,
        autoOpen: false,
        width: 660,
        buttons: {
            "Close": function() { 
                $(this).dialog("close"); 
                $(this).remove();
            }
        }
    });

    // Dialog Link
    $('.dialog_link').click(function(){
        var vurl = $(this).attr("rel");
        var diadiv = $('div#dialog');
        if (diadiv.length &lt; 1) 
        {
            $('#divwrapper').append('&lt;div id="dialog"&gt;&lt;object width="480" height="385"&gt;&lt;param name="movie" value="'+vurl+'"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="'+vurl+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;').hide();
        }
        else
        {
            var vurl = $(this).attr("rel");
            var dicont = $('div#dialog').html();
            var newcont = dicont.replace("{VIDURL}",vurl);
            $('div#dialog').html(newcont);
        }
        $('div#dialog').dialog('open');
        return false;
    });
});
</code></pre>

<p>LINKS:</p>

<pre><code>&lt;a href="javascript:void()" rel="http://www.youtube.com/v/WiBA0lS_lwg&amp;amp;hl=en_US&amp;amp;fs=1" id="vl1" class="dialog_link"&gt;Open Dialog&lt;/a&gt;

&lt;a href="javascript:void()" rel="http://www.youtube.com/v/QQORnYPqU3A&amp;amp;hl=en_US&amp;amp;fs=1" id="vl2" class="dialog_link"&gt;Open Dialog&lt;/a&gt;
</code></pre>
