Uncaught TypeError: Cannot read property 'element' of undefined

Uncaught TypeError: Cannot read property 'element' of undefined

Hello Guys:

I'm working with ASP .Net and JQuery, i'm developing a MsgBox Dialog control (ascx) the control work's successfuly but i can't display it on Chrome, Opera, Safari and Firefox this browsers send the next error: Uncaught TypeError: Cannot read property 'element' of undefined.... 

The MsgBox dialog only appear in IE, i don't know what's happen, the code that i wrote to display this MsgBox dialog is

<script>
  Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);
  function EndRequest(sender, args) {
    var loMsgBox = '#' + $('.MsgBox')[0].id;

    if ($(loMsgBox).attr("show") === 'true') {
      showDialog(loMsgBox);
    }
  }

  function showDialog(tsMsgBox) {
    var dialog = $(tsMsgBox).data('dialog');

    if (!dialog.element.data('opened')) {
        dialog.open();
        $(tsMsgBox).attr("show", false);
    } else {
        dialog.close();
    }
  }
</script>