We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Knockout Custom BInding

Thread ID:

Created:

Updated:

Platform:

Replies:

113851 Oct 12,2013 04:23 AM UTC May 27,2014 10:52 AM UTC JavaScript 5
loading
Tags: ejTools
Samps
Asked On October 12, 2013 04:23 AM UTC

I'm trying to create a binding handler for the datepicker. When I create the picker the events do not fire and the calendar will not open. If I create the datepicker in the viewAttached function of the viewmodel the calendar opens and closes. I would like to handle this in a ko handler. Can you provide a ko binding handler for the datePicker?

ko.bindingHandlers.datePicker = {
    init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {

        $(element).ejDatePicker();     

    },
    update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {

    }
};

Saravanan G [Syncfusion]
Replied On October 15, 2013 01:15 PM UTC

Hi Samps,

 

Thanks for using Syncfusion products.

 

We are sorry for inconvenience caused. We are unable to reproduce the issue, We have prepared a simple sample and the same can be downloaded from the following links.

KO binding.zip

Could you please try the above sample and get back to us whether you are able to reproduce the issue? If not, could you please give more information or by reproducing the issue in the above sample so that we could sort out the issue and provide you with solution. The information provided would be of great help in resolving the issue.

 

Please let us know if you have any concerns.

 

Regards,

Saravanan G



KO_binding_34432d04.zip

Samps
Replied On October 23, 2013 04:46 AM UTC

Thanks Saravanan. I should have mentioned that I am using Durandal.js. This library loads the view after the DOM has been rendered. If I use SetTimeout, the control will work. This appears to be a known issue with Durandal. I may be able to get this to work using jQuery deferred since setting a timeout is not a good solution.

ko.bindingHandlers.ejDatePicker = {
    init: function (element, valueAccessor, allBindingsAccessor, viewModel) {
        setTimeout(function () {
            var el = $(element);
            el.ejDatePicker();
            var modelValue = valueAccessor();
            var value = ko.utils.unwrapObservable(valueAccessor());            
            el.val(value);
            }, 1000);
    },
    update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
    }
};

Thanks,
Samps

Saravanan G [Syncfusion]
Replied On October 25, 2013 01:11 PM UTC

Hi Samps,

 

Thanks for your update.

 

We suspect that this issue is not from our side, we will call the KO model once the control is completely rendered, otherwise we can use the delay rendering logic using setTimeOut function as you mentioned in the update.

 

Please let me know if you have any other query.

 

Regards,

 

Saravanan G


Hostilio
Replied On March 12, 2014 02:56 PM UTC

Can Saravanan G [Syncfusion] please re upload the example, i am trying to download it but shows an error


Harikrishnan P [Syncfusion]
Replied On May 27, 2014 10:52 AM UTC

Hi Hostilio,

 

Thanks for using Syncfusion products.

 

We have reattached the sample (KO binding handler for DatePicker control) and the same can be downloaded from the below location,

 

Sample location: KObinding

 

Please let us know if you have further queries.

Regards,

HariKrishnan.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;