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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:05:42+00:00 2026-06-10T18:05:42+00:00

I am relatively new to Javascript/Ajax. When the user clicks on certain urls, I

  • 0

I am relatively new to Javascript/Ajax.

When the user clicks on certain urls, I wish to handle the click entirely with Javascript/jquery.

<a class="row_edit" href="/sales_item/edit/{{ item.id }}"></a>

What I have done is to add a javascript to this html file:

   $(document).ready(function () {  
        $(".row_edit").click(row_edit);
    });

   function row_edit() {
      var url = $(this).attr("href") + "/";
      ...
   }

This works pretty well, every time I click on row_edit, the javascript is firing and doing the partial site loading for me. But there are cases that it seems the actual link would fire instead (I see the partial site loaded as the entire screen). It seems there is a race condition.

I think the best way to make sure only the javascript is firing would be to change the content of the href to #. That way I make sure the url by itself won’t go anyway and only my javascript is firing. However how would I get my url value in the row_edit() then?

Maybe I am taking a wrong approach here though. How do you guys solve this problem?

  • 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-10T18:05:44+00:00Added an answer on June 10, 2026 at 6:05 pm

    To make sure only the javascript is firing (Cancel the default action (navigation) of the click), you have to call the preventDefault(); in the click handler.

    Ex:

    $(document).ready(function () {  
            $(".row_edit").click(row_edit);
        });
    
       function row_edit(event) {
          var url = $(this).attr("href") + "/";
          ...
          event.preventDefault();
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Being relatively new to javascript, AJAX and jQuery, I want to post 3 values
I am very new to javascript and ajax/jquery and have been working on trying
I'm relatively new to web programming. New to Javascript, PHP, Ajax, etc. I have
I'm still relatively new to javascript and jQuery and was just wondering this. Suppose
i'm relatively new to jquery and javascript and am trying to pass a unique
Disclaimer: I'm relatively new to jQuery and JavaScript. The openStatement() function below executes whenever
I'm relatively new javascript, but I am comfortable in other languages. I'm trying to
Relatively new to JavaScript, so wondering what is the best approach to achive the
I am relatively new to Javascript so I'm hoping this is a simple mistake.
I'm relatively new with WordPress theming and JavaScript, though not incompetent with either. I'm

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.