What is wrong with this dialog code?

What is wrong with this dialog code?

$(function() {
$('a.writemsg').click(function() {
var uid = $(this).attr('id');
        //console.log(uid);
$('dialog_'+uid).dialog({
autoOpen: false,
show: 'blind',
hide: 'fold',
width: 300,
                height: 300,
            modal: true,
            buttons: {
                'Send message': function() {
                    var bValid = true;
                    bValid = bValid && checkLength(note,"note",3,255);
                    if (bValid) {
                        console.log(bValid);
                        //$('#users tbody').append('<tr>' +
                        //    '<td>' + note.val() + '</td>' +
                        //    '</tr>');
                        $(this).dialog('close');
                    }
                },
                Cancel: function() {
                    $(this).dialog('close');
                }
            },
            close: function() {
                //allFields.val('').removeClass('ui-state-error');
            }
}).dialog('open')
});
});
uid is a number say 8.
HTML Code
<span class="sprite-email_edit"><a href="javascript:void(0);"
id="#pendingReqs.id#" class="writemsg">Write Message</a></span>
<div id="dialog_#pendingReqs.id#" title="Send note"
style="display:none">
    <form>
    <fieldset>
        <label for="name">Note:</label>
        <input type="text" name="note" id="note_#pendingReqs.id#"
class="text ui-widget-content ui-corner-all" />
    </fieldset>
    </form>
<button id="sendnote_#pendingReqs.id#" class="ui-button ui-state-
default ui-corner-all">Send note</button>
</div>
also if I remove the display:none, the form shows inline. Didn't think
I had to do that to make it not show?
Thx,
Derek
--