dineshd87
dineshd87

Reputation: 139

Knockout js: Datepicker binding handler not working

This is my fiddle. http://jsfiddle.net/aaScC/4/

In the example, for the StartDate property custom binding handler is created to get jquery datepicker. But its not working please help.

var Goal = function(goal)
{
    this.GoalTitle = ko.observable(goal?goal.GoalTitle:"");
    this.StartDate = ko.observable(goal?goal.StartDate:"");


    this.lstSubGoals = ko.observableArray(goal ? ko.utils.arrayMap(goal.lstSubGoals, function (goal) { return new Goal(goal) }) : []);

}

Upvotes: 0

Views: 855

Answers (1)

John Earles
John Earles

Reputation: 7194

  1. Move the call to ko.applyBindings after your declaration of the custom binding
  2. Bring in jqueryUI and it's CSS
  3. daterestriction function is not found

Working fiddle: http://jsfiddle.net/aaScC/5/

--

ko.bindingHandlers.datepicker = {
    init: function (element, valueAccessor, allBindingsAccessor) {
      ...
    },
    update: function (element, valueAccessor) {
      ...
    }
};

ko.applyBindings(new GoalsModel(data), document.getElementById("goaldetailsdiv"));

Upvotes: 1

Related Questions