0

My html binding code is:

<input class="input-large" name="EventDate" type="text" placeholder="" tabindex=""
                                required data-bind="datepicker: EventDate, datepickerOptions: {
    changeMonth: false,
    changeYear: false,
    numberOfMonths: 1,
    showButtonPanel: true,
    dateFormat: 'd MM, yy',
    autoSize: true,
    prevText: 'Earlier',
    minDate: new Date(),
    showAnim: 'fold'
}" />

How can i set the value into EventDate = ko.observable() using knockout js view model.

Shohel
  • 3,886
  • 4
  • 38
  • 75

1 Answers1

0

Just create an observable in a view model -

function viewModel() {
    var self = this;
    self.EventDate = ko.observable();
}

ko.applyBindings(new viewModel());

And call that in a document ready event handler of some sort.

You need to make sure to have a datepicker custom binding handler registered also.

PW Kad
  • 14,953
  • 7
  • 49
  • 82
  • Then just look for one - http://stackoverflow.com/questions/13629910/jquery-ui-datepicker-with-knockout-js – PW Kad Dec 14 '13 at 16:42