All Components

MVVM / Strongly typed binding

Event manager

Log

HTML5/JavaScript 源码

<!DOCTYPE html>
<html>
 <head> 
  <title>Strongly typed binding</title> 
  <meta charset="utf-8"> 
  <link href="../content/shared/styles/examples-offline.css" rel="stylesheet"> 
  <link href="../../styles/kendo.common.min.css" rel="stylesheet"> 
  <link href="../../styles/kendo.rtl.min.css" rel="stylesheet"> 
  <link href="../../styles/kendo.default.min.css" rel="stylesheet"> 
  <link href="../../styles/kendo.dataviz.min.css" rel="stylesheet"> 
  <link href="../../styles/kendo.dataviz.default.min.css" rel="stylesheet"> 
  <script src="../../js/jquery.min.js"></script> 
  <script src="../../js/kendo.all.min.js"></script> 
  <script src="../content/shared/js/console.js"></script> 
  <script>
        
    </script> 
 </head> 
 <body> 
  <a class="offline-button" href="../index.html">Back</a> 
  <div id="example"> 
   <div class="demo-section k-content"> 
    <form id="eventForm" novalidate> 
     <h4>Event manager</h4> 
     <ul> 
      <li> <label for="Event">Event:</label> <select name="Event" class="k-input" data-type="date" data-bind="value: EventDate"> <option value="2014-12-31">New Year's Eve</option> <option value="2015-01-01">John's Birthday</option> <option value="2015-07-11">Jane's Welcome Party</option> </select> </li> 
      <li> <label for="Attendees">Attendees:</label> <input type="number" name="Attendees" class="k-input" data-bind="value: Attendees"> </li> 
      <li> <label for="Extra">Extra guests allowed:</label> <label>No<input type="radio" name="Extra" data-type="number" data-bind="checked: AllowedExtra" value="0"></label> <label>One<input type="radio" name="Extra" data-type="number" data-bind="checked: AllowedExtra" value="1"></label> <label>Two<input type="radio" name="Extra" data-type="number" data-bind="checked: AllowedExtra" value="2"></label> </li> 
     </ul> 
    </form> 
   </div> 
   <script>
        $(document).ready(function () {
            var viewModel = kendo.observable({
                EventDate: kendo.parseDate("2015-07-11", "yyyy-MM-dd"),
                AllowedExtra: 1,
                Attendees: 10
            });
            kendo.bind($("#example"), viewModel);
            viewModel.bind("change", function (e) {
                kendoConsole.log(e.field + " = " + this.get(e.field));
            });
        });
    </script> 
   <div class="box"> 
    <h4>Log</h4> 
    <div class="console"></div> 
   </div> 
   <style scoped="">
                #eventForm ul {
                    list-style-type: none;
                    margin: 0;
                    padding: 0;
                }

                #eventForm li {
                    margin-top: 10px;
                }

                label {
                    display: inline-block;
                    padding-right: 3px;
                }

                .k-input {
                    width: 160px;
                }
            </style> 
  </div>   
 </body>
</html>