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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:22:35+00:00 2026-06-06T05:22:35+00:00

I am trying to modify the href in an anchor before the click is

  • 0

I am trying to modify the href in an anchor before the click is submitted.

However the following creates an infinite loop:

$('.preview').live('click', function(e){
    e.preventDefault();
    var _this = this;
    var content = $('#redactor_content').getCode();
    var page_id = $('#page_id').val();
    $.ajax({
        url: ADMIN_CORE_URL + 'pages/autosave.php',
        dataType: 'json',
        type: 'POST',
        data: {page_id : page_id, content : content},
        success: function(data){
            var url = $(_this).attr('href') + data.revision_id;
            $(_this).attr('href', url);
            $(_this).unbind('click').click();
        }
    });
});

Either I cant get the click to submit or I get the loop.

How do I re-enable the click without the loop?

  • 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-06T05:22:37+00:00Added an answer on June 6, 2026 at 5:22 am

    you could try something like this.
    that way the handler only gets executed if the link has class x (or whatever you want to call it).
    after the ajax response, remove the class and the click handler shouldn’t be executed anymore.

    $(body).on('click', '.preview.x', function(e){
        e.preventDefault();
        var _this = this;
        var content = $('#redactor_content').getCode();
        var page_id = $('#page_id').val();
        $.ajax({
            url: ADMIN_CORE_URL + 'pages/autosave.php',
            dataType: 'json',
            type: 'POST',
            data: {page_id : page_id, content : content},
            success: function(data){
                var url = $(_this).attr('href') + data.revision_id;
    
    
                // $(_this).attr('href', url);
                // $(_this).removeClass('x').click();
                //
                // edit: version 2:
                window.open(url);
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to modify anchor tag href ausing jQuery as per below, but I
I'm trying to modify an object on a click. Here's what I have. <form>
I'm trying to modify the following query to find the rank of a specific
I’m trying to modify a string of the following form where each field is
I am trying to modify a function to be more sensible for my purposes;
I am trying to modify the size of a column in a table, however
I'm trying to slightly modify a wordpress template. At the moment a function returns
I'm trying to modify a request made by HtmlUnit before it gets sent out,
I'm trying to modify the following code so that it will return a Dictionary<int,int>
I am trying to modify the script below to click a button that looks

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.