JavaScript DHTML/Dojo toolkit/ComboButton

Материал из Web эксперт
Версия от 07:20, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Add Icon to ComboButton MenuItem

 
<html>
  <head>
    <link rel="StyleSheet" type="text/css"
      href="js/dojo/dijit/themes/tundra/tundra.css">
    <script type="text/javascript">
      var djConfig = {
        baseScriptUri : "js/dojo/",
        parseOnLoad : true
      };
    </script>
    <script type="text/javascript" src="js/dojo/dojo/dojo.js"></script>
    <script>
        dojo.require("dojo.parser");
        dojo.require("dijit.form.Button");
        dojo.require("dijit.Menu");
        function save_function() {
           alert("Save");
        }
        function save_as_function(choice) {
           alert("Save As");
        }
    </script>
  </head>
  <body class="tundra">
    <div dojoType="dijit.form.ruboButton" onclick="save_function">
    <span>File</span>
        <div dojoType="dijit.Menu" id="saveMenu" toggle="fade" style="display: none;">
                <div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconSave" onclick="save_function">
                    Save
                </div>
                <div dojoType="dijit.MenuItem" onclick="save_as_function">
                    Save As
                </div>
        </div>
    </div>
  </body>
</html>



ComboButton click event

 
<html>
  <head>
    <link rel="StyleSheet" type="text/css"
      href="js/dojo/dijit/themes/tundra/tundra.css">
    <script type="text/javascript">
      var djConfig = {
        baseScriptUri : "js/dojo/",
        parseOnLoad : true
      };
    </script>
    <script type="text/javascript" src="js/dojo/dojo/dojo.js"></script>
    <script>
        dojo.require("dojo.parser");
        dojo.require("dijit.form.Button");
        dojo.require("dijit.Menu");
        function save_function() {
           alert("Save");
        }
        function save_as_function(choice) {
           alert("Save As");
        }
    </script>
  </head>
  <body class="tundra">
    <div dojoType="dijit.form.ruboButton" onclick="save_function">
    <span>File</span>
        <div dojoType="dijit.Menu" id="saveMenu" toggle="fade" style="display: none;">
                <div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconSave" onclick="save_function">
                    Save
                </div>
                <div dojoType="dijit.MenuItem" onclick="save_as_function">
                    Save As
                </div>
        </div>
    </div>
  </body>
</html>



ComboButton MenuItem click event

 
<html>
  <head>
    <link rel="StyleSheet" type="text/css"
      href="js/dojo/dijit/themes/tundra/tundra.css">
    <script type="text/javascript">
      var djConfig = {
        baseScriptUri : "js/dojo/",
        parseOnLoad : true
      };
    </script>
    <script type="text/javascript" src="js/dojo/dojo/dojo.js"></script>
    <script>
        dojo.require("dojo.parser");
        dojo.require("dijit.form.Button");
        dojo.require("dijit.Menu");
        function save_function() {
           alert("Save");
        }
        function save_as_function(choice) {
           alert("Save As");
        }
    </script>
  </head>
  <body class="tundra">
    <div dojoType="dijit.form.ruboButton" onclick="save_function">
    <span>File</span>
        <div dojoType="dijit.Menu" id="saveMenu" toggle="fade" style="display: none;">
                <div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconSave" onclick="save_function">
                    Save
                </div>
                <div dojoType="dijit.MenuItem" onclick="save_as_function">
                    Save As
                </div>
        </div>
    </div>
  </body>
</html>