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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:42:20+00:00 2026-05-29T18:42:20+00:00

What should happen is the page loads, it calls the server for information about

  • 0

What should happen is the page loads, it calls the server for information about the order (at this point its just a list of possible order types and the id of the current type of the order). After the load the value of the select should be set to “selected_order_type” which it is.

However it looks like it just selecting it in the list and not actually setting the “value” of the select item to the current value. So for instance in my example it selects the 2nd option on load. If i then click the third option everything works if instead I clicked the first option first nothing happens and I am assuming it because the still had the first options value even though it was showing the second option as the selected option. (very new to knockout been using it for a couple hours just trying to get my head around how it works).

<select id="order_type_select"
                    data-bind="options:order_types,
                      optionsText:'order_type',
                      optionsValue:'order_type_id',
                      value:selected_order_type"/>

function update_order_field(order_id,field,value){
    var url = '/op/update_order_field'
    data = {'order_id':order_id,'field':field,'value':value};
    console.log(url);
    console.log(data);
}

function refresh_order_data(order_id,view_model){
    $.getJSON("/op/order_json/"+order_id,function(data){
        ko.mapping.fromJS(data,view_model);
    });
    console.log(view_model.selected_order_type);
}

function OrderData(){
    var self = this;
    self.order_types = [{}]
    self.selected_order_type = '0'
    return self
}

$(document).ready(function() {
    var order_id = $("#order_id").attr('order_id');
    var view_model = ko.mapping.fromJS(new OrderData());
    view_model.selected_order_type.subscribe(function(data){
        console.log(data);
    });
    refresh_order_data(order_id,view_model);
    ko.applyBindings(view_model);
});

Data coming in from server on initial load …

{
    order_types: [
        { order_type_id=1, order_type="Phone"},
        { order_type_id=2, order_type="Fax"},
        {order_type_id=3, order_type="Web"}
    ],
    selected_order_type = '2' 
}   
  • 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-05-29T18:42:24+00:00Added an answer on May 29, 2026 at 6:42 pm

    Problem was server side. Although I have no idea why as the output on the client is identical. I wrapped the returning value in json.dumps using python and everything works as intended

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

Sidebar

Related Questions

I can't seem to get this working, what should happen is when the user
How can WCF client detect that server requires security certificate? The detection should happen
I am working on a simple AJAX page. when the page loads, it should
I have this page which loads quotes. It has a search form wherein if
Here is what I want to happen: The user should click a link/button that
Should entry_set be cached with select_related? My DB is still getting calls even after
I have a search page that loads results. Each row has a Delete button
So I make a call for records with JQuery when the page loads like
I have a 'tabbed' style web page where once the page loads each tab
i call my UI dialog from page which has scriptManager, this way: function openDialog()

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.