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

  • Home
  • SEARCH
  • 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 8616145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:32:55+00:00 2026-06-12T05:32:55+00:00

First of all, I know you can use Computed observables. They are really great

  • 0

First of all, I know you can use Computed observables. They are really great for complex properties, but IMO are not a worthy replacement for the IValueConverters you have in Silverlight.
In my current project, I have multiple datepickers. Right now, I have to create an extra computed observable for each date, because I want the formatting to work. So If I have 5 dates that’s 10 properties, where in Silverlight you would have 5 dates and 1 generic dateconverter.

It works, but it’s not very clean code.. Not to mention the issues you get when applying validation to these dates..

Is there something like:

<input type="text" data-bind="value: TestProperty" data-converter="MyTextConverter" />

Or is there any alternative to this which doesn’t let me create double properties?

Thanks in advance,

Arne Deruwe

  • 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-12T05:32:56+00:00Added an answer on June 12, 2026 at 5:32 am

    You’re looking at a prime use for a custom-binding. See here for a good guide

    ko.bindingHandlers.dateConverter = {
      init: function (element, valueAccessor, allBindingsAccessor) {
        var underlyingObservable = valueAccessor();
        var options = allBindingsAccessor().dateConverterOptions
                        || { /* set defaults here */ };
    
        var interceptor = ko.computed({
          read: function() {
            return underlyingObservable();
          },
    
          write: function(newValue) {
            var current = underlyingObservable(),
                convertedDate;
    
            /* do some kind of conversion here, using the 'options' object passed */
    
            if (convertedDate !== current) {
              underlyingObservable(convertedDate);
            }
            else if (newValue !== current.toString()) {
              underlyingObservable.valueHasMutated();
            }
          }
        });
    
          ko.applyBindingsToNode(element, { value: interceptor });
      }
    };
    

    Interceptor code modified from here

    Edit:

    And your html would look like:

    <input type="text"
           data-bind="dateConverter: TestProperty,
                      dateConverterOptions: { format: 'dd/mm/yyyy', anotherOption: 'example' } " />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all, I know that UDP is not a reliable protocol but I
First of all I know similar questions has been asked here, I've checked but
First of all i don't know whether the title is relevant or not (please
First of all sorry for the name of the title, but i dont know
I know you can use python and other scripting languages in android. But I
First of all, I want you to know that I really like OpenCV. I
First of all: I do know that there are already many questions and answers
First of all I don't know if this is the right approach. I want
first of all i would like to say i know its probably an easy
First of all, I know there are a few quite similar questions here on

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.