Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 7th, 2012  |  syntax: None  |  size: 1.99 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. knockout wizard   Jquery
  2. ....
  3. <script id="step1" type="text/html">    
  4.  <div>Name: <input type="text" data-bind="value: Name"></div>
  5.  <div>Description: <input type="text" data-bind="value: Description"></div>
  6. </script>
  7.  
  8. <script id="step2" type="text/html">
  9.   Start: <br/><input type="text" id="from"  data-bind="value: StartDate">
  10.   Stop:<br/> <input type="text" id="to" class="required" data-bind="value: EndDate">
  11. </script>
  12. .....
  13.        
  14. $(function () {
  15.   $("#from").datepicker({
  16.     showOn: "button",
  17.     buttonImage: "/Content/images/calendar.gif",
  18.     buttonImageOnly: true,
  19.     defaultDate: "+1w",
  20.     changeMonth: true,
  21.     numberOfMonths: 1,
  22.     onSelect: function (selectedDate) {
  23.         $("#to").datepicker("option", "minDate", selectedDate);
  24.     }
  25. });
  26. $("#to").datepicker({
  27.     showOn: "button",
  28.     buttonImage: "/Content/images/calendar.gif",
  29.     buttonImageOnly: true,
  30.     defaultDate: "+1w",
  31.     changeMonth: true,
  32.     numberOfMonths: 1,
  33.     onSelect: function (selectedDate) {
  34.         $("#from").datepicker("option", "maxDate", selectedDate);
  35.     }
  36. });
  37. });
  38.        
  39. // call this before you call ko.applyBindings()
  40.     ko.bindingHandlers.datepicker = {
  41.          init: function(element, valueAccessor, allBindingsAccessor) {
  42.              // initialize here
  43.          },
  44.          update: function(element, valueAccessor, allBindingsAccessor) {
  45.              // change handler here
  46.          }
  47.     };
  48.        
  49. <br/>
  50.     Start :<input type="text" id="from" data-bind="datepicker: StartDate, datepickerOptions: {onSelect: $root.onSelectStartDate()}" />
  51.     <br/>
  52.     End :<input type="text" id="to" data-bind="datepicker: EndDate, datepickerOptions: {onSelect: $root.onSelectEndDate()}" />
  53.        
  54. function ViewModel() {
  55.  
  56.         // ...
  57.  
  58.         self.onSelectStartDate = function() {
  59.             return function() {
  60.                 alert("Start Date selected");
  61.             };
  62.         };
  63.  
  64.         self.onSelectEndDate = function() {
  65.             return function() {
  66.                 alert("End Date selected");
  67.             };
  68.         };
  69.     };