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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:42:17+00:00 2026-05-15T17:42:17+00:00

I am trying to basically disable the click event on a <div> temporarily. I

  • 0

I am trying to basically disable the click event on a <div> temporarily.

I have tried the following (preview):

$('hello').observe('click', function (e) {
    e.stop();
});

$('hello').observe('click', function (e) {
    alert('click not stopped!');
});

However, when #hello is clicked, the alert box still appears. I do not want the second attached handler to be called, and I do not want to change the second handler.

I will also accept a solution such as:

$('hello').observe('click', function (e) {
    alert('click not stopped!');
});

$('hello').disableEvent('click');

// Now, handler won't be called

$('hello').observe('click', function (e) {
    alert('click not stopped (2)!');
});

// New handler won't be called, either

$('hello').enableEvent('click');

// Now, handler will be called

I am using the Prototype.js framework. This doesn’t seem to be a browser-specific issue.

  • 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-15T17:42:18+00:00Added an answer on May 15, 2026 at 5:42 pm

    As I said in comments to roosteronacid’s answer, I wrote an extension to Event.observe. Works in most browsers, but not IE.

    // XXX HACK XXX
    (function () {
        var handlerCache = $A([ ]);
    
        function findHandler(either) {
            var pair = handlerCache.find(function (pair) {
                return $A(pair).member(either);
            });
    
            return pair && pair[0];
        }
    
        function addHandler(handler) {
            function newHandler(e) {
                if (!e.halted) {
                    handler.apply(this, arguments);
                }
            }
    
            handlerCache.push([ handler, newHandler ]);
    
            return newHandler;
        }
    
        Event.observe = Event.observe.extended(function ($super, element, eventName, handler) {
            handler = findHandler(handler) || addHandler(handler);
    
            $super(element, eventName, handler);
        });
    
        Event.stopObserving = Event.stopObserving.extended(function ($super, element, eventName, handler) {
            handler = findHandler(handler) || handler;
    
            $super(element, eventName, handler);
        });
    
        Element.addMethods({
            observe: Event.observe
        });
    
        Event.prototype.halt = function () {
            this.halted = true;
        };
    }());
    

    Note: Function.prototype.extended is a custom function which puts the original Event.observe in as $super.

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

Sidebar

Related Questions

I'm basically trying to make my js and css files dynamic. I've tried a
I am basically trying to trigger a function if the footer is inside the
I'm basically trying to convert a Unix timestamp (the time() function) to a relative
I'm basically trying to do a dropdown jquery plugin. HTML <script type='text/javascript' src='script.js'></script> <div
I'm basically trying to get the target element from event.target and if not equal
Using Rails 3.2.0 with haml, sass and coffeescript: Basically I am trying to disable
I am trying to basically call a function from another javascript file (inside a
The following code snippet is a simplified version of my issue. Basically I'm trying
Hello I have following HTML, <article id=jobwall> <ul> <li class=box>Hello World</li> <li class=box>Hello World</li>
I'm basically trying to disable the scroll on List View. Which can be done

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.