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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:55:24+00:00 2026-06-04T04:55:24+00:00

I already subscribe the function to listen the property value change using ko. var

  • 0

I already subscribe the function to listen the property value change using ko.

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

var postbox = new ko.subscribable();
var myViewModel =
{
    FirstName: ko.observable( "Bert" ),
    LastName: ko.observable( "pual" )
};
var sub = null;
for ( var i in myViewModel ) {
    var model = myViewModel[i];
    model.subscribe( self.notifyChange.bind( model, i ) );

}

$( '#unsubscribeButton' ).click( function () {
    // here i want to unsubscribe.
} );
 ko.applyBindings( myViewModel );
  });
 notifyChange = function ( PropName, newValue ) {
var self= this;
);
    }

here i want to unsubscribe the notifyChange from myViewModel’s property one by one, how to do this?

  • 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-04T04:55:25+00:00Added an answer on June 4, 2026 at 4:55 am

    Store results of call to subscriptions in a variable (or, in your case, in an array).

    When you want to unsubscribe, simply call dispose on each subscription.

    Fully described here – http://knockoutjs.com/documentation/observables.html

    Your code will look like this:

    //store subscriptions in array
    var subscriptions = [];
    
    for ( var i in myViewModel ) {
        var model = myViewModel[i];
        subscriptions.push(model.subscribe( self.notifyChange.bind( model, i ) ));
    }
    
    
    //unsubscribe
    for(var i in subscriptions) {
        subscriptions[i].dispose(); //no longer want notifications
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my code for adding a row: grid.onAddNewRow.subscribe(function (e, args) { var item
Already found this page with some helpful hints. Problem is I need to debug
I am using fb connect using js. This is my code: <script> window.fbAsyncInit =
What are some of the feeds you subscribe too? I already have a feed
I already asked a similar question but this one is a bit different/specific: I'm
I need to subscribe to database changes using an Observer in an app widget.
I'm using Rails 3 for this one. I've got a collections model, a user
FB.Event.subscribe('auth.login', function(response) { FB.api('/me', function(response){ //Some operation });}); Above piece of JavaScript code runs
The question I have is how I would be able to change the value
We'd like to override DataGridView's default behavior when using a mouse wheel with this

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.