Open dialog on a single click?

Open dialog on a single click?

I have the following code, however, I need to click twice on Change password for the dialog to open.  I want the dialog to open when on a single click.  I can`t understand why the dialog doesn`t open on a single click.
 
  1. <td><a href="#" id="password_link" onclick="$(ChangeAttribute('<%= item.Name %>', '<%=item.ID %>'));">Change Password</a> </td>

  2. function ChangeAttribute(name, Id) {

    $(

    "#ID").val(Id);

    $(

    "#DivPassword")

    .dialog(

    'open');

    $(

    'a.ui-dialog-titlebar-close').remove();

    $(

    '#DivPassword').dialog({

    autoOpen:

    false,

    title: $(

    '#DivPassword').attr('title') + name,

    width: 400

    });

    }