Loading ...
Sorry, an error occurred while loading the content.

21335Focus not set on dialog when shown via script

Expand Messages
  • mhaertl73
    Nov 23, 2007
    • 0 Attachment
      Hi,

      i want to show a dialog on context menu click. Therefore i use a
      function to set some dialog properties and show it. The focus never
      gets set - even if i try to call focus() on the input element manually.

      If i trigger dialog.show() with a button click, everything works.

      Any ideas?
      Thanks
      Mike

      <script type="text/javascript">
      YAHOO.util.Event.onDOMReady( function() {
      var showDialog=function(o) {
      // focus will not be set:
      markupDialog.show();
      }
      contextMenu = new YAHOO.widget.ContextMenu("myContext", { trigger:
      "menuTest"});
      contextMenu.addItem( {text: "Show dialog", onclick: { fn: showDialog
      } });
      contextMenu.render(document.body);

      var markupDialog=new YAHOO.widget.Dialog("markupDialog", { width :
      "300px", visible : false,
      buttons : [ { text:"OK" } ]
      });
      markupDialog.render();

      // focus will be set:
      YAHOO.util.Event.addListener("mybutton", "click", markupDialog.show,
      markupDialog, true);
      });
      </script>


      <div id="menuTest" style="width:200px; height:100px; border: 2px solid
      #ccc">Right click here</div>

      <div id="markupDialog">
      <div class="hd">Testdialog</div>
      <div class="bd"><form action="#"><input type="text"></form></div>
      </div>

      <button id="mybutton">Show Dialog</button>
    • Show all 4 messages in this topic