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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:36:56+00:00 2026-06-17T08:36:56+00:00

I have 2 questions about my code: Why is input image disabled (no hand

  • 0

I have 2 questions about my code:

Why is input image disabled (no hand cursor on hovering) but when the TreeDiv has any element (tree exists) and a node is selected the input image is still disabled. Its not getting enabled.

Why this?

I would also like to know why I need the viewmodel instance its used nowhere… (thats code from the authors site)

<input type="image" id="CreateSiblingUnit" data-bind="value: selectedUnit,enable: isUnitSelected"  src="~/Content/Images/unitaddsibling.png" title="Create sibling unit"  data-url="@Url.Action("CreateSibling", "Unit")" />

var viewModel = {
                isUnitSelected: ko.observable(false),
                selectedUnit: $('#TreeDiv').children().length > 0 && $("#TreeDiv").dynatree("getActiveNode") != null
            };

ko.applyBindings(viewModel);
  • 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-17T08:36:57+00:00Added an answer on June 17, 2026 at 8:36 am

    In your view model,

    isUnitSelected: ko.observable(false),
    

    defines isUnitSelected as an observable with an initial value of false, but I can’t see anything that would ever set it to true. Your binding (enable: isUnitSelected) will therefore cause it to be disabled until something alters the value of isUnitSelected.

    I’m a bit confused by your two properties in the view model. The first will always be false, and the second will be a boolean, so the name “selectedUnit” doesn’t make much sense.

    I’m not sure what dynatree is, but I’d imagine you probably need to bind to some kind of event (when a node is selected etc), and set the properties in your view model accordingly. E.g.

    // In your view model:
    isUnitSelected: ko.observable(false),
    selectedUnit: ko.observable()
    
    // In some event handler, update the view model's properties each time a node is clicked
    var hasNodes = ($('#TreeDiv').children().length > 0);
    var activeNode = null;
    if (hasNodes) {
        activeNode = $("#TreeDiv").dynatree("getActiveNode");
    }
    selectedUnit(activeNode);
    isUnitSelected(hasNodes && activeNode !== null);
    

    The viewModel is used in the line:

    ko.applyBindings(viewModel);
    

    In this case your viewModel is just a basic Javascript object. You could also use the slightly more complex (but ultimately more useful) syntax like so, which would allow you to create an instance of a view model “object”:

    var ViewModel = function() {
        var self = this;
    
        self.isUnitSelected = ko.observable(false);
        //...
    }
    
    ko.applyBindings(new ViewModel());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have couple of questions about AS3 variables handling by AVM/compiler/scope .1. This code
A quick questions about sessions, I have a session with the following code <?php
I have seen questions here asking about xsd->actionscript objects, but these seem to require
I know questions about reversing linked lists have been asked before but I want
I have seen some other questions about this but the errors were related to
I have a question about the following code in TCL/EXPECT: expect { timeout {
I have a question about the following code : #include <iostream> #include <ctime> int
So I just have posted a question about this code (which was answered): $(document).ready(Main);
I have a question about the following C code: void my_function() { int i1;
I have a question about defining Foreign Key in EF Code First Fluent API.

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.