2013-10-03 149 views
0

當我點擊按鈕它必須顯示對話框,但它不顯示。我從dojo文檔中找到了這個代碼。當我點擊按鈕時,它沒有顯示任何東西。這裏是我的代碼,請幫助我。對話框沒有顯示在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> 

回答

0

檢查,以查看是否有

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

某處添加到頭部。當我添加它它工作正常。

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

+0

是的,我需要聲明 – sirisha

+1

你有parseonload作爲djConfig的一部分。因爲在小提琴中看到,您的代碼工作。 – tik27

0

看來你的道場沒有加載在所有。爲了避免解析問題,我總是在調用最新版本的dojo腳本時導入dojo庫djConfig="parseOnLoad:true

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>