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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:25:55+00:00 2026-06-02T00:25:55+00:00

i am working on a webpage that consists a JQuery item and a Knockout

  • 0

i am working on a webpage that consists a JQuery item and a Knockout Item.

basically the view has a select field and a sevond view that is being updated by the select value change.

also i have a textbox search field with jquery autocomplete.

What i want to do is when i press enter after on the search box, the javascript will update the ko.observable value and trigger the ther updates yet its not working. i’ve managed to trigger keypress but i cant update and trigger the update..

Heres the code:

        function Station(data){
        var self = this;
        this.userId = ko.observable(data.userid);
        this.displayName = ko.observable(data.displayName);
        this.email = ko.observable(data.email);
        this.redirectURL = ko.computed(function(){
            return "/someurl/somerequest?userId="+self.userId();
        });
        this.selectText = ko.computed(function(){
            return self.displayName();
        })
    }

    function currentStation(index)
    {
        return self.stations()[index];
    }

    function StationViewModel(){
        var self = this;
        self.stations = ko.observableArray([]);

        $("#stationSelect").attr("disabled,true");
        $.getJSON("@{someurl.getStationList()}",function(allData){
            var mappedStations = $.map(allData,function(item)
                    {
                    return new Station(item);
                    });
            self.stations(mappedStations);
            $("#stationSelect").attr("disabled,false");
        });

        url = "/someurl/somerequest?userId=";

        this.selectedStation = ko.observable();
        this.redirectToStation = function(){
            var linkToSend = 
            alert(self.selectedStation.redirectURL());
        }


<!-- THIS IS THE CODE THAT HAS TO UPDATE THE FIELD BUT IT DOESN'T-->
        this.getStation = function(event)
        {
            for(i = 0; i<this.stations().length;i++)
                {
                    if(this.stations()[i].userId()==$("#search").val())
                        {
                        self.selectedStation = ko.observable(this.stations()[i]);  //Am i doing it right?
                        }
                }
        };
    }


<!-- This is the code That handles the click event inside the textbox. its working -->

    ko.bindingHandlers.executeOnEnter = {
            init: function (element, valueAccessor, allBindingsAccessor, viewModel) {
                var allBindings = allBindingsAccessor();
                $(element).keypress(function (event) {
                    var keyCode = (event.which ? event.which : event.keyCode);
                    if (keyCode === 13) {
                        allBindings.executeOnEnter.call(viewModel);
                        return false;
                    }
                    return true;
                });
            }
        };
    ko.applyBindings(new StationViewModel());
    </script>
  • 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-02T00:25:57+00:00Added an answer on June 2, 2026 at 12:25 am

    Instead of

    self.selectedStation = ko.observable(this.stations()[i]);

    do

    self.selectedStation(this.stations()[i]);

    Hope this helps!

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

Sidebar

Related Questions

I'm currently working in an application that has to navigate a webpage and recollect
I'm working on a webpage that has a javascript image rotator, but it needs
I've got a webpage that I'm working on where you click on a letter
I am working on a web page that has a large number of tables.
I'm working on a PHP dynamic web page that has a <textarea> element that
I have a webpage that has a button that sends a letter on the
I have a webpage that has to be displayed in several different languages based
I am currently updating a webpage that has some very simple data displayed in
i develop a webpage in that i need to add value field and text
I'm working on a webpage that involves using the Blueprint CSS Framework, as this

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.