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 8770983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:40:27+00:00 2026-06-13T17:40:27+00:00

I am using knockout.js. I am stuck in a little bit strange situation (

  • 0

I am using knockout.js. I am stuck in a little bit strange situation ( its hard to explain but i am trying, sorry if i am not clear ). I am using custom binding and options binding on a single select-list :

  <select data-bind="options : arrayOfOptions, optionsText: 'Name', 
           optionsValue: 'Name', chosen: { }">
  </select>

ko.bindingHandlers.chosen = {
    init: function (element, valueAccessor, allBindingAccessor, 
                    viewModel, bindigContext) {
        var options = ko.utils.unwrapObservable(valueAccessor() || {});
        $(element).chosen(options);
    }
};

Here at runtime selectlist will fill with all available options from the arrayOfOptions array and chosen is a custom binding in which i am applying a CHOSEN PLUGIN on the select-list.

Now the problem i am facing here is that in custom binding when i applied choose plugin on select list at that time the selectlist is not filled with the options from the arrayOfOptions array. Means in a simple term the custom binding is executing before options binding. Can anybody please give me a solution for this so that custom binding applied after options binding?

  • 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-13T17:40:29+00:00Added an answer on June 13, 2026 at 5:40 pm

    Move your call to chosen into the update.

    http://jsfiddle.net/jearles/avSfa/28/

    —

    ko.bindingHandlers.chosen = {
        init: function(element, valueAccessor, allBindingsAccessor, viewModel) {
            var allBindings = allBindingsAccessor();
    
            var options = {default: 'Select one...'};
            $.extend(options, allBindings.chosen)
    
            $(element).attr('data-placeholder', options.default);                
        },
        update: function(element, valueAccessor, allBindingsAccessor, viewModel) {
            $(element).chosen();
        }
    };
    

    —

    Alternatively, you can use setTimeout to move the call to chosen to the bottom of the execution queue. This will give the Knockout options binding time to do its work before chosen tries to transform it.

    ko.bindingHandlers.chosen = {
        init: function (element, valueAccessor, allBindingAccessor, 
                        viewModel, bindingContext) {
            var options = ko.utils.unwrapObservable(valueAccessor() || {});
            setTimeout(function() { $(element).chosen(options); }, 0);
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A bit of a mystery has cropped up using knockout (2.1.0) and knockout mapping
I am trying to create a group of dropdowns using knockout out that allow
I'm using Knockout-sortable to drag-and-drop/sort records in my table, but I've run into a
I am trying to update a dropdown using knockout and data retrieved via an
Using Knockout.JS, I'm trying to determine how to best extend objects in the view
I’ve been using Knockout.js quite extensively but there’s one pattern I use a lot
Using knockout, I need to reset certain templates, not the entire form. resetForm() resets
I am using knockout.js with its inbuilt templating system. I define the templates as
I am using knockout for the first time and I am trying to make
I am using knockout with jquery template, I am stuck in a place in

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.