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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:41:42+00:00 2026-06-17T22:41:42+00:00

Do Raphael sets accept event handler? When I set an event handler on a

  • 0

Do Raphael sets accept event handler? When I set an event handler on a raphael set, it seems that it is instead assigned on each of the Raphael shapes inside the set and not on the set itself as you can see here if you try to click the set:

http://jsbin.com/aponen/3/edit

I’m not interested in various hacks such as chaining elements inside a set with the set itself via custom attributes or similar approaches.

Thanks

  • 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-17T22:41:44+00:00Added an answer on June 17, 2026 at 10:41 pm

    Yes, the event handler is applied to each object individually — Raphael does not make use of the <g> element of SVG. However, you can fix your issue here with a few keystrokes:

    set.push(rect);
    set.push(circle);
    set.attr({'fill': 'yellow'});
    set.click(function(evt) {
        //old
        this.attr({'fill': 'red'});
        //new
        set.attr({'fill': 'red'});
    });
    

    The biggest difference in the way it works and the way you thought it might work is the meaning of “this” inside the handler. Changing it to “set” will fix that right up.

    UPDATE, Jan. 26, 2013
    Per comments, you could also attach the set to the children of the set with one line, using Raphael’s “data” method:

    set.push(rect);
    set.push(circle);
    
    set.data('myset', set);
    
    set.attr({'fill': 'yellow'});
    set.click(function(evt) {
      this.data('myset').attr({'fill': 'red'});
    });
    

    I don’t believe there is a native way to access the set from children, but I could be missing it.

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

Sidebar

Related Questions

I have a Raphael paper containing multiple sets. Each set has a rect, a
I have a Raphael text element with both a mouseup and click event handler.
I've got a Raphael.js image that I've done, which consists of a set of
I have a Raphael set that I'd like to move by 400px vertically. When
I have an Raphael element with click event handler: var paper = Raphael(container, 770,
I am using Raphael to draw some paths. Each path has an associated rectangle
I've just discovered Raphael, and love it, but I am not much of a
I'm using the Raphael library to draw some shapes, and then animate them into
I'm using Raphael 2.1 to draw 15 lines at the same time. Each lines
I´m working with Raphael, and I think that I´m using it in a way

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.