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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:15:16+00:00 2026-06-05T21:15:16+00:00

Ok, in my code I have for example, this: $(‘.follow’).click(function(){ var myself = $(this);

  • 0

Ok, in my code I have for example, this:

$('.follow').click(function(){
        var myself = $(this);
        var data = {
            id: this.getAttribute('data-id')
        }
        $.post('/users/setFriend', data, function(msg){
            myself.text(msg);
            myself.attr('data-status-friends', (myself.attr('data-status-friends').toLowerCase() == 'follow') ? 'following' : 'follow');
        });
    })

However, i put a class of ‘auth’ on certain elements that if the user is logged out, run this bit of JS:

$('.auth').click(function(e){
    e.preventDefault();
    alert('not logged in');
});

This works for the majority of elements, but with the above POST, it seems to still action the POST. How can I definitively cancel the events fired by other bits of code if .auth is clicked?

  • 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-05T21:15:17+00:00Added an answer on June 5, 2026 at 9:15 pm

    I don’t think we should talk about propagation or defaultAction preventing here. The point is that you create two different series of event handlers: one attached to the .follow elements, another – to the .auth elements. Of course, if an element has two classes, clicking it will trigger both handlers automatically – and they both will be attached to this element (hence no propagation).

    The most simple solution here, I think, is to remove click handler from an element when you assign .auth class to it.

    Or, alternatively, you can check $(this).hasClass('auth') condition within the .follow handler function – and return false immediately if that’s the case.

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

Sidebar

Related Questions

I have this example code: var foo = { self: this, init: function(){ self.doStuff();
I have this example code, but i believe when i call the ajax function
I have this example http://jsbin.com/ipasu3/4/ When you click on a div code it hides
I have code like this: var client = new mysql.Client(options); console.log('Icanhasclient'); client.connect(function (err) {
I have this example: Click! With the following jquery: $(.abox-1).click(function(){ $(#box-2, #box-3).css({ zIndex: -999
Suppose we have this example: http://techdroid.kbeanie.com/2009/07/custom-listview-for-android.html with source code available here: http://code.google.com/p/myandroidwidgets/source/browse/trunk/Phonebook/src/com/abeanie/ How can
For example we have this line chart at Google Code API there is a
I have this code (an example that PHP generates for me)... <select id=outsideBlue3> <option
we have this example: http://code.google.com/apis/maps/documentation/v3/basics.html#DetectingUserLocation which shows how to get the user's position in
I have this example simple code to enable and disable a form according to

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.