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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:11:11+00:00 2026-06-04T02:11:11+00:00

Is there is any way to find which property is calling the subscribed function,

  • 0

Is there is any way to find which property is calling the subscribed function, when we subscribe one function to more then one property ?

code example.

var self = this;
$(document).ready(function(){

var myViewModel = 
{
    FirstName : ko.observable("Bert"),
    LastName : ko.observable("pual")
};
myViewModel.FirstName.subscribe(self.notifyChange);

myViewModel.LastName.subscribe(self.notifyChange);

ko.applyBindings(myViewModel);
});
notifyChange = function ( newValue ) {// want to find which property(FirstName/LastName) is calling the function }

HTML

<body>
Enter your name:
<input id="source" data-bind="value: FirstName" />
<input id="Text1" data-bind="value: LastName" />    

here i subscribed the “notifyChange” function for both FirstName and LastName. if any one value is changed means,it will call the notifyChange function, i want to know which property changes make the notifyChange function call ?

  • 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-04T02:11:16+00:00Added an answer on June 4, 2026 at 2:11 am

    You can’t tell who actually called the function.

    One choice would be to use your notifyChange function, but bind it in each case to the appropriate property. Now, this will be set to either the FirstName or LastName observable. Doing a bind does create a wrapper to the function, but at least your actual implementation in notifyChange will only exist once.

    myViewModel.FirstName.subscribe(self.notifyChange.bind(myViewModel.FirstName));
    myViewModel.LastName.subscribe(self.notifyChange.bind(myViewModel.LastName));
    

    So, this inside of notifyChange will be the appropriate observable.

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

Sidebar

Related Questions

Is there any way to find particular C language function's input and output parameters
Is there any way to find out if a property is mapped to a
Is there any way to find the parent directory of a path using NSFileManager
Is there any way to find out diagonals of quadrilateral if I only know
Is there any way to find the number of bytes of memory that are
is there any way to find out new version of application is available on
Using regular expressions in C#, is there any way to find and remove duplicate
What have I marked as --assume-unchanged ? Is there any way to find out
I have a table with many rows, is there any way to find out
Is there any way I can find out in my app if the user

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.