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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:10:29+00:00 2026-06-12T19:10:29+00:00

Basically I want visible: to fire up only on the div i hover over,

  • 0

Basically I want visible: to fire up only on the div i hover over, but it applies to all of them,
no matter which one I hover over.

I guess that makes sense, since I am binding to visible: inside foreach: loop, so it is applied to all of them. Is there a KnockoutJS work-around, or should I just use $jQuery.hover() to make it work instead?

Html:

<div>
 <div data-bind="foreach: hostGroups">
  <div data-bind="css: { style: true }, event: { mouseover: $root.showDeleteLink, mouseout: $root.hideDeleteLink }">
   <span data-bind="text: hostName"></span>
   <span class="delete-link" data-bind="visible: $root.deleteLinkVisible">this is a delete link</span>
  </div>
 </div>
</div>​

JavaScript:

var data = [ 
    { "hostName": "server1" }, 
    { "hostName": "server2" }, 
    { "hostName": "server3" }
]; 

var viewModel = {

    hostGroups: ko.observableArray(data),

    deleteLinkVisible: ko.observable(false),

    showDeleteLink: function() {
         viewModel.deleteLinkVisible(true);
    },

    hideDeleteLink: function() {
        viewModel.deleteLinkVisible(false);
    }

};  

ko.applyBindings(viewModel);

http://jsfiddle.net/pruchai/KXtTU/3/

  • 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-12T19:10:30+00:00Added an answer on June 12, 2026 at 7:10 pm

    You should implement hiding and showing the link on each individual item instead of on the root view model. For example:

    JavaScript:

    var data = [
        {
        "hostName": "server1"},
    {
        "hostName": "server2"},
    {
        "hostName": "server3"}
    ];
    
    function Item(hostName) {
        var self = this;
        this.hostName = ko.observable(hostName);
        this.deleteLinkVisible = ko.observable(false);
        this.showDeleteLink = function() {
            self.deleteLinkVisible(true);
        };
        this.hideDeleteLink = function() {
            self.deleteLinkVisible(false);
        };
    }
    
    function ViewModel() {
        var self = this;
    
        this.hostGroups = ko.observableArray(ko.utils.arrayMap(data, function(item) {
            var newItem = new Item(item.hostName);
            return newItem;
        }));
    
    }
    
    var viewModel = new ViewModel();
    
    ko.applyBindings(viewModel);​
    

    Html:

    <div>
     <div data-bind="foreach: hostGroups">
      <div data-bind="css: { style: true }, event: { mouseover: showDeleteLink, mouseout: hideDeleteLink }">
       <span data-bind="text: hostName"></span>
       <span class="delete-link" data-bind="visible: deleteLinkVisible">this is a delete link</span>
      </div>
     </div>
    </div>​
    

    Example: http://jsfiddle.net/KXtTU/4/

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

Sidebar

Related Questions

I basically want to do: git checkout branchA git checkout -b branchB <commit_id> which
I basically want the same functionality as facebook, twitter and all those other infinite
Basically I want to know if a given nodes children are visible in a
Basically, I want to use BeautifulSoup to grab strictly the visible text on a
I basically want to change a non-visible function of a package. For visible functions,
Any ideas how to implement tipsy tooltips over jQuery's UI Datepicker? Basically I want
I basically want a dispatcher timer object to only execute once. So I have
I basically want to add arrow if the mousehover my navigation. But two rules
Basically I want the entire OS X desktop (or ideally everything but the menubar)
I've played with all the showAsAction values to no avail. I basically just want

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.