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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:25:44+00:00 2026-06-10T17:25:44+00:00

I have a custom object in JavaScript: function Graph (dataType, provider){ this.dataType = dataType;

  • 0

I have a custom object in JavaScript:

function Graph (dataType, provider){
   this.dataType = dataType;
   this.provider = provider;
}

I instantiate this object via "new" and then pass it to other parts of my code that may need to keep track of changes to this object’s properties.

When the properties of the Graph object are modified, I want all other consumers of that object to be notified. In languages like C# I would have a setter in which I would raise an event. What is a proper way to create events in custom JavaScript objects?

  • 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-10T17:25:45+00:00Added an answer on June 10, 2026 at 5:25 pm

    Using JQuery, you can create and also attach events of any type to whatever object you want, at any time.

    function Graph (dataType, provider){
       this.dataType = dataType;
       this.provider = provider;
    }
    
    var g = new Graph;
    
    g.dataType = "whatever1";
    g.provider = "whatever2";
    g.event = $.Event("mywhateverEvent");
    g.myOwnProperty2 = $.Event("thisisAnEventToo");
    

    Now you can manipulate your event further, doing whatever you want to that event, using something like:

    g.event = <whateverCodeIWant>;
    g.myOwnProperty2 = <whateverCodeIwant2>
    

    Since you seem to like constructors, you can also do it like this:

    function Graph (dataType, provider, evt){
       this.dataType = dataType;
       this.provider = provider;
       this.evt = evt
    }
    
    var myevt =  $.Event("whateverEvent");
    myevt = <codeTomanipulatemyEventFurtherNowIfIWantTo>;
    var g = new Graph("datawhatever", "providerwhatever", myevt);
    $("whateverIWant").bind(myevt); 
    //or whatever other binding - it will bind to that very event
    $("whateverIWant").bind(g.evt);//equivalent to above line- binds to same event object
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom Javascript object that I create with new , and assign
I have a custom object that I was adding to an array via a
I'm hoping someone can help on this one, I have created a custom object
In a simple aspx page I can have a custom JavaScript function postback as
Suppose I create a custom object/javascript class (airquotes) as follows: // Constructor function CustomObject(stringParam)
I have a JavaScript object called ShippingUI: function ShippingUI(){ ... } It has several
So I have a newly created Javascript object called EditableObject in my custom .js
I have a javascript object that looks like this, var telephones = { /*
I'm new to creating custom object in JavaScript, so it could easily be something
I have an array of a custom JavaScript object which has a property named

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.