Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8362711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:00:15+00:00 2026-06-09T12:00:15+00:00

I have a wizard contains 4 step with knockout its work fine but when

  • 0

I have a wizard contains 4 step with knockout its work fine but when i added datepicker of Jquery on step 2 date picker doesn’t display (just an input type text display) if i refresh my browser it display, but i lose information of step 1 (if i refresh my browser), how can i solve my problem,

my wizard its like this: http://jsfiddle.net/FyuSD/36/

wizard.cshtml:

....
<script id="step1" type="text/html">    
 <div>Name: <input type="text" data-bind="value: Name"></div>
 <div>Description: <input type="text" data-bind="value: Description"></div>
</script>

<script id="step2" type="text/html">
  Start: <br/><input type="text" id="from"  data-bind="value: StartDate">
  Stop:<br/> <input type="text" id="to" class="required" data-bind="value: EndDate">
</script>
.....

DatePicker.js:

 $(function () {
  $("#from").datepicker({
    showOn: "button",
    buttonImage: "/Content/images/calendar.gif",
    buttonImageOnly: true,
    defaultDate: "+1w",
    changeMonth: true,
    numberOfMonths: 1,
    onSelect: function (selectedDate) {
        $("#to").datepicker("option", "minDate", selectedDate);
    }
});
$("#to").datepicker({
    showOn: "button",
    buttonImage: "/Content/images/calendar.gif",
    buttonImageOnly: true,
    defaultDate: "+1w",
    changeMonth: true,
    numberOfMonths: 1,
    onSelect: function (selectedDate) {
        $("#from").datepicker("option", "maxDate", selectedDate);
    }
});
});

I’m sorry for my bad English

thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:00:16+00:00Added an answer on June 9, 2026 at 12:00 pm

    I played with the fiddle a bit and your solution is the answer to this question

    jQuery UI datepicker change event not caught by KnockoutJS

    Which shows a datepicker implementation for custom bindings as described in the knockout documentation: Knockout – Custom Bindings

    You need to create a custom binding handler that will initialize your datepickers when the template is rendered.

        // call this before you call ko.applyBindings()
        ko.bindingHandlers.datepicker = {
             init: function(element, valueAccessor, allBindingsAccessor) {
                 // initialize here
             },
             update: function(element, valueAccessor, allBindingsAccessor) {
                 // change handler here
             }
        };
    

    When you declare your data bindings use the name of your custom binding (instead of “value: StartDate”)

        <br/>
        Start :<input type="text" id="from" data-bind="datepicker: StartDate, datepickerOptions: {onSelect: $root.onSelectStartDate()}" /> 
        <br/>
        End :<input type="text" id="to" data-bind="datepicker: EndDate, datepickerOptions: {onSelect: $root.onSelectEndDate()}" /> 
    

    Of course $root refers to your ViewModel class so that means you need some methods there. This is where you could put your minDate and maxDate code.

        function ViewModel() {
    
            // ...
    
            self.onSelectStartDate = function() {
                return function() {
                    alert("Start Date selected");
                };
            };
    
            self.onSelectEndDate = function() {
                return function() {
                    alert("End Date selected");
                };
            };
        }; 
    

    I tested it in an updated fiddle here http://jsfiddle.net/carbontax/bwA4N/5/. It looks funny because the datepicker css is not available, but the binding handler is doing the right thing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form wizard that contains 3 forms. Basically, what I am trying
Ok. I have a mainframe which contains two containers. One contains my wizard-alike buttons
Good Afternoon All, I have a wizard control that contains 20 textboxes for part
I have started using jQuery Validation plugin 1.7. I have a wizard like interface
I have a solution that contains a setup project(made with VS2008 setup wizard). I
I have an asp:wizard control that contains five WizardSteps. All of these steps have
I have a wizard setup like so: <asp:Wizard ID=Wizard1 runat=server DisplaySideBar=false onnextbuttonclick=OnNextButtonClick> <WizardSteps> <asp:WizardStep
I have a wizard in my app where users can go back and forward
I have a Wizard with two pages: pageone extending WizardNewProjectCreationPage , and pagetwo is
I am writing an Eclipse plugin, and I have a wizard that create my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.