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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:15:24+00:00 2026-06-06T02:15:24+00:00

I am using knock out for my binding purposed and i am working on

  • 0

I am using knock out for my binding purposed and i am working on a share module. basically, there are couple of links and they all are basically calling the same function just with different values. For example, when you click on the Facebook then all the service with value “Facebook” and when and when you click on Twitter then call the function with the value “Twitter”. But basically calling the same function. Now that there is not way to specify parameters from HTMl because all I can do is something like data-bind=”click: Share”. Here we cans see that I can not specify any parameters here.

Now I can create an ko.observable in my js file which this function will take as an argument… but I need a way to write on that observable from html click event when different links are clicked. Any idea on how to do it?

  • 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-06T02:15:26+00:00Added an answer on June 6, 2026 at 2:15 am

    Knockout passes the current context to any function used in data binding. This means that if you call click: share it will pass in the service you have bound. Here is a fiddle demonstrating this, but I’ll put in the code here since its pretty basic.

    For more complex bindings, your object will likely have a name property, which you can use in place of $data, as well as use in your share() function.

    HTML:

    <ul data-bind="foreach: services">
        <li data-bind="text: $data, click: $parent.share" />
    </ul>​
    

    Javascript:

    data = [
    "Facebook",
    "Twitter",
    "Flickr",
    "SomeOtherWeb2.0 Service"
    ];
    
    var ViewModel = function(data) {
        this.services = ko.observableArray(data);
        this.share = function(service){
            alert("You Clicked on: " + service);
        };
    
    };
    
    ko.applyBindings(new ViewModel(data));​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Linq 2 Sql to knock out a quick bespoke CMS. I
I am creating a list of links using a knockout binding: The Javascript and
I'm currently successfully using knockout.js to handle all of my data-binding in my application.
I've a graph chart like below made using css and knockout.js (binding) Depending on
Here is my dilemma, I am working on some SaaS using ASP.net MVC3 and
I am binding a list of objects to a select using knockout. Object Class
How, if at all, are people making web applications with client side activity using
I am using LABjs to load in a vast amount of javascript, and all
I am using knockout.js with jquery ui button. I built a custom binding on
I'm using the options binding on a select list used in a jQuery template:

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.