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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:45:52+00:00 2026-05-27T08:45:52+00:00

In .NET you can add multiple handlers to an event which an object declares

  • 0

In .NET you can add multiple handlers to an event which an object declares as an event.

What is the recommended way for handling this in JavaScript for non-DOM objects?

i.e. I have an object:

var ProblemDomainObj = {} ;
ProblemDomainObj.Changed = function() {} ;
ProblemDomainObj.Data = { somedata : "initialized" } ;
ProblemDomainObj.Operate = function (newdata) {
    if (newdata != somedata && ProblemDomainObj.IsValid(newdata)) {
        somedata = newdata;
        ProblemDomainObj.Changed();
    }
} ;

Now other objects may want to register to know that the data has changed and each want to do something like this:

ProblemDomainObj.Changed += function() {
     /* Do stuff to reflect the object model changes */
} ;

Where each gets to register their handler without overwriting the other.

Then some object will call ProblemDomainObj.Operate(foo); and all those who have subscribed will get notified.

I have found the documentation in jQuery for http://api.jquery.com/on/ but it seems to relate to DOM events like onclick. None of this would necessarily be related to the DOM.

  • 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-05-27T08:45:53+00:00Added an answer on May 27, 2026 at 8:45 am

    jQuery works great on regular objects as well: http://jsfiddle.net/gMNkg/.

    var ProblemDomainObj = {};
    
    ProblemDomainObj.Data = { somedata : "initialized" };
    
    ProblemDomainObj.Operate = function () {
        $(ProblemDomainObj).trigger("foo"); // run bound functions
    };
    
    
    // bind 2 functions
    
    $(ProblemDomainObj).on("foo", function() {
        alert(123);
    });
    
    $(ProblemDomainObj).on("foo", function() {
        alert(456);
    });
    
    
    ProblemDomainObj.Operate();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to add multiple queries to the SqlCommand object in .net? And
I would like to setup a admin page (ASP.NET/C#) that can add IIS host
I want to extend the basic ControlCollection in VB.NET so I can just add
I want to subclass the built-in DropDownList in ASP.NET so that I can add
When creating a DomainService, within .NET Ria Services and using Subsonic I can add
can I add BehaviorID attribute for asp.net textbox and use it to be recognize
Can I add new Silverlight 2.0 projects to my ASP.NET 2.0 web app and
Im a VB.NET beginnger, can anyone tell me how I can dynamically add a
I have made a custom UserControl i Vb.net (windows application). How can I add
When sending email using the SMTPClient class in ASP.NET C#, how can I add

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.