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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:57:36+00:00 2026-06-13T12:57:36+00:00

I want to catch an error, correct it and continue executing the program. http://jsfiddle.net/Gthv9/12/

  • 0

I want to catch an error, correct it and continue executing the program.
http://jsfiddle.net/Gthv9/12/

But, I can’t do it!

If you click on: “re Check On Model1”, “re Check On Model3” – it’s ok.

If you click on: “re Check On Model1”, “re Check On Model2”, “re Check On Model3” – there’s an error.

Uncaught Error: Unable to parse bindings.
Message: ReferenceError: name3 is not defined;
Bindings value: text: name3 

Why?

I wrapped the problem code in a try-catch block (viewModel.recheckData2() ),
but, the application crashes on clicking viewModel.recheckData3() !

I know that knockoutJS stores the error state (new model2()), but don’t know what I should do.

How can I catch the error properly?

Thanks!

  • 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-13T12:57:37+00:00Added an answer on June 13, 2026 at 12:57 pm

    I am not sure that I understand your exact goal, but Knockout will stop binding when it runs into this type of an issue.

    If your issue is simply undefined variables, then one trick that you can use is to bind against $data.name3 rather than just name3. Accessing a undefined property off of a valid object does not cause an error.

    If you really want something more robust, then you could consider using a custom binding provider.

    For example, you could write a quick wrapper to the real binding provider like:

    var ErrorHandlingBindingProvider = function() {
        var original = new ko.bindingProvider(); 
    
        //determine if an element has any bindings
        this.nodeHasBindings = original.nodeHasBindings;
    
        //return the bindings given a node and the bindingContext
        this.getBindings = function(node, bindingContext) {
            var result;
            try {
                result = original.getBindings(node, bindingContext);
            }
            catch (e) {
                if (console && console.log) {
                    console.log("Error in binding: " + e.message);   
                }
            }
    
            return result;
        };
    };
    
    ko.bindingProvider.instance = new ErrorHandlingBindingProvider();
    

    This would catch errors, log them, and proceed. Of course the element that had this “bad” binding would not bound. If there is some known way that you want to handle it, then you could add that logic after catching the error. Maybe you want to inspect that element (node) and the bindingContext to determine what needs to be done.

    Sample: http://jsfiddle.net/rniemeyer/KxXqs/

    UPDATE: Here is a version for 3.0+ that traps/logs errors in binding syntax as well as errors when the bound value is actually evaluated. http://jsfiddle.net/rniemeyer/ecbn1dmy/

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

Sidebar

Related Questions

I want to catch a fancybox error (The requested content cannot be loaded. Please
I am using codeplex NVelocity library on .net and i want to catch an
I want a way to check in my catch {} clause if the exception
i am new on asp.net. i want to know how to check my username
How can I make sure that after I catch an error and log it
i want to catch the data from server as an answer and alert it.
I want to catch exceptions thrown by classes implementing Processor interface. In aspect I
-I want to raise an event whenever method showmessage is called.I want to catch
This is my below code and I want to catch the exception if any
I'm making a background app A in android, and want to catch the touch

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.