dojo中没有显示对话框

时间:2013-10-03 05:02:06

标签: javascript dojo dialog

当我点击按钮时,它必须显示对话框,但它没有显示。我从dojo文档中找到了这段代码。当我点击按钮时,它没有显示任何内容。这是我的代码,请帮助我。

<script type="text/javascript">
dojo.require("dijit.form.Form");
dojo.require("dijit.Dialog");
dojo.require("dijit.form.Button");
dojo.require("dojo.parser");
dojo.require("dijit.form.TextBox");

</script>

<body class="claro">
<div id="gridDiv"></div>

 <div data-dojo-type="dijit.Dialog" id="formDialog2"
    title="Filtering Rows" style="display: none">
    <form data-dojo-type="dijit.form.Form" id="123">
        <script type="dojo/event" data-dojo-event="onSubmit"
            data-dojo-args="e">

              require(["dojo/dom"], function(dom){
        var f = dojo.byId("123");
        var s = "";
            var elem = f.elements[0];
            s = elem.value;
 dijit.byId('grid').filterBar(s);

    });
   return false;

    </script>
        Search: <input type="text" name="searchtext" value=""
data-dojo-type="dijit/form/TextBox">
        <div class="dijitDialogPaneActionBar">
            <button data-dojo-type="dijit.form.Button" type="submit">OK</button>
            <button data-dojo-type="dijit.form.Button" type="button"
data-dojo-props="onClick:function(){dijit.byId('formDialog2').hide();}">Cancel</button>
        </div>
    </form>
</div>

<button id="buttonThree" data-dojo-type="dijit.form.Button"
    type="button">
    Show Filter
    <script type="dojo/method" data-dojo-event="onClick"
        data-dojo-args="evt">
    dijit.byId("formDialog2").show();
</script>
</button> 

   

2 个答案:

答案 0 :(得分:0)

检查您是否有

require(["dijit/Dialog",'dijit/form/TextBox','dijit/form/Button']); 

添加到某个地方。当我添加它它工作正常。

http://jsfiddle.net/theinnkeeper/HX4uR/

答案 1 :(得分:0)

看来你的道场根本没有加载。为了避免解析问题,我总是在调用最新版本的dojo的脚本时用djConfig="parseOnLoad:true导入dojo库。

 dojo.require("dijit.form.Form");
 dojo.require("dijit.Dialog");
 dojo.require("dijit.form.Button");
 dojo.require("dojo.parser");
 dojo.require("dijit.form.TextBox");
<link href="http://ajax.googleapis.com/ajax/libs/dojo/1.6.2/dojo/resources/dojo.css" rel="stylesheet" />
<link href="http://ajax.googleapis.com/ajax/libs/dojo/1.6.2/dijit/themes/claro/claro.css" rel="stylesheet" />
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.9.3/dojo/dojo.js" djConfig="parseOnLoad:true"></script>

<body class="claro">
  <div id="gridDiv"></div>

  <div data-dojo-type="dijit.Dialog" id="formDialog2" title="Filtering Rows" style="display: none">
    <form data-dojo-type="dijit.form.Form" id="123">
      <script type="dojo/event" data-dojo-event="onSubmit" data-dojo-args="e">

        require(["dojo/dom"], function(dom){ var f = dojo.byId("123"); var s = ""; var elem = f.elements[0]; s = elem.value; dijit.byId('grid').filterBar(s); }); return false;

      </script>
      Search:
      <input type="text" name="searchtext" value="" data-dojo-type="dijit/form/TextBox">
      <div class="dijitDialogPaneActionBar">
        <button data-dojo-type="dijit.form.Button" type="submit">OK</button>
        <button data-dojo-type="dijit.form.Button" type="button" data-dojo-props="onClick:function(){dijit.byId('formDialog2').hide();}">Cancel</button>
      </div>
    </form>
  </div>

  <button id="buttonThree" data-dojo-type="dijit.form.Button" type="button">
    Show Filter
    <script type="dojo/method" data-dojo-event="onClick" data-dojo-args="evt">
      dijit.byId("formDialog2").show();
    </script>
  </button>


</body>

</html>