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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:30:15+00:00 2026-06-09T19:30:15+00:00

Is there a way to activate the subscribe, when we change something using jquery

  • 0

Is there a way to activate the subscribe, when we change something using jquery ?

for example:

var MyModel = function (){
 var self = this;
 this.ImageUrl= ko.observable("Image.jgp");
}

var Model = new MyModel (); 
ko.applyBindings(Model);
Model.ImageUrl.subscribe(function (NewValue)
{
console.log(NewValue);
})

<img data-bind:"attr{src: ImageUrl}" id ="image1" src = "" alt= "new image"/>

and I am using jquery to change the src:

$("#button1").click(function(){
$("#image1").attr("src","image2.jpg");
})

this is a little example, I am not sure if this is the best option.

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

    The attr binding is a one-way binding, so it does not react to changes to the element (does not handle any events).

    Knockout does include two helper functions called ko.dataFor and ko.contextFor that can give you the current data/context given a DOM element. Here are the docs that we have on it: http://knockoutjs.com/documentation/unobtrusive-event-handling.html.

    So, basically, if you want to attach your event handler via jQuery, then you would want to use ko.dataFor to get your data and then update your ImageUrl observable directly.

    Here is a sample: http://jsfiddle.net/rniemeyer/gbruu/

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

Sidebar

Related Questions

I need to activate this mail() function is there any way of doing this
Using System.AddIn, is there a way to load and activate an AddIn without locking
is there a way to activate a git hook remotely? I am using some
Is there way to set @include mixin(); to variable? I tried this @mixin bg-gradient($fallback,
Is there way that I can read the file from remote server using fopen
Is there any way to activate intellisense for xsl:fo documents? Writting all that tags
Is there another way to activate an accordion menu besides the .accordion('activate', indexval); method?
Is there a way to activate an entire DOM to be draggable and resizable
Is there a way to create a script that will change the preferences of
Is there a way to activate Skype / some SIP clients / Viberer and

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.