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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:00:42+00:00 2026-06-13T13:00:42+00:00

Here is the set up: A user is on the page A. There is

  • 0

Here is the set up:

A user is on the page “A”. There is a dropdown (DROPDOWN) used for navigation.
There are 2 options user can pick from: A, B. Where A represents the current page and B is something the user wants to go to.

This dropdown is bound to a dependent observable (GUARD) which can read and may or may NOT write to another regular observable (TARGET) that holds the state of that dropdown.

DROPDOWN <– –> GUARD <– ?–> TARGET

The idea is that if the user picks something in the dropdown to navigate away from the page first we check if there are any unsaved changes and if there are, we ask the user whether he wants to discard them or stay on the page and continue editing.

So the situation:
There are unsaved changes. The user picks something from the dropdown. The GUARD kicks in by getting its ‘write’ method called. We prompt the user if he wants to discard changes and navigate off the page or stay. The user chooses to stay. We say ‘fine’ and the write method doesn’t do anything, so the target observable stays intact. End of story! But..

As the user touched the dropdown and the ‘change’ even wasn’t cancelled (there are no means for doing it inside a bound observable) the drop down got to state “B” as if the user chose to navigated off the page.

So my question is simple:

  • Is there a way to cancel the ‘change’ event from withing the ‘write’ method of the dependent observable the dropdown is bound to?

  • If no, how do I get out of this situation keeping the selection of the dropdown in sync with the TARGET observable?

  • 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-13T13:00:43+00:00Added an answer on June 13, 2026 at 1:00 pm

    The ‘change’ event occurs after the dropdown has already changed, so a simple solution would be to cause the dropdown to “refresh” using the old value, easily done with a call to target.valueHasMutated().
    Example fiddle: http://jsfiddle.net/KXhem/77/

    Edit: Since knockout 3, computed’s only notify if their value has really changed. To get the same behavior you can add .extend({ notify: 'always' }) to the computed.
    See the full details here: http://knockoutjs.com/upgrade-notes/v3.0.0.html

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

Sidebar

Related Questions

On a page, something like jsFiddle, that executes user inputed Javascript, is there a
How can i find all subsets of a set using c#? here set is
Here is the problem from code chef : A set of N dignitaries have
Here is how our current php development solution is set up: Each developer work
How can I pass user control properties to the page AND make these properties
General Problem: I'm trying to create something similar to this: The user can select
I have problem passing a variable from a main page containing a user control
I have a form where there are two dropdown lists that are populated from
I'm trying to implement this simple example in JSF: There is a user.xhtml page
Is there a way to set or reset color box options later, after events,

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.