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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:11:00+00:00 2026-05-27T21:11:00+00:00

Given the nature of the project I’m working on, I’m trying to avoid using

  • 0

Given the nature of the project I’m working on, I’m trying to avoid using plugins for scalability sake. However, if it turns out a plugin is what’s needed, I’m open to suggestions.

First off, I’m having success in my jQuery pagination script, in that using predefined (in my coldfusion script) hyperlinks of class “loadLink”, I’m able to produce 10 rows of data per page in a new table that gets processed and displayed inside a div tag. In addition, I’m able to get it to re-sort the data in that paginated table of records by clicking on one of the headers I want to sort by. Just like the page links, it sends an ajax call to a CF component that reproduces the table with the new sort intact.

All that works fine, but here is where I’m hitting a big problem. Every time I choose a new page of records to view, I can still execute one new sort of that data. However, when I try to do a second sort of any column, the script reloads itself rather than makes another ajax call. In essence, the click function does not get turned on, even though I think I do have it turned on again. I know I’m missing something but here is the code I’m using:

$(document).ready(function() {
// load the first page of records upon initial load.
$("##mydiv").load("generateInfo.cfc?method=getEmailData", function() {
    $(".sortLink").on("click", function(e) {
        e.preventDefault();
        var recorddata = $(this).attr("href").substring(1); //trim '?' char
        $.ajax({
            type: "GET",
            url: "generateInfo.cfc?method=getEmailData",
            data: recorddata,
            dataType: "html",
            success: function(message) {                            
                $("##mydiv").html(message);
            }
        });
    });
});

$(".loadLink").click(function(e) {
    e.preventDefault();
    var recorddata = $(this).attr("href").substring(1); //trim '?' char
    var curElement = $(this);
    if ($(this).attr("id") != "disabledLink") {
        $.ajax({
            type: "GET",
            url: "generateInfo.cfc?method=getEmailData",
            data: recorddata,
            dataType: "html",
            success: function(message) {
                $('##pageLinks').children('a').each(function () {
                    if ($(this).attr("id") == "disabledLink") {
                        $(this).removeAttr("disabled");
                        $(this).removeAttr("id");
                    }
                });
                curElement.attr("disabled","disabled");
                curElement.attr("id","disabledLink");
                $("##mydiv").html(message);
                $(".sortLink").on("click", function(e) {
                    e.preventDefault();
                    alert($(this).attr("class"));
                    var recorddata = $(this).attr("href").substring(1); //trim '?' char
                    $.ajax({
                        type: "GET",
                        url: "generateInfo.cfc?method=getEmailData",
                        data: recorddata,
                        dataType: "html",
                        success: function(message) {                            
                            $("##mydiv").html(message);
                            $(".sortLink").on("click");
                        }
                    });
                });
            }
        });
    }
});
});

What am I missing here or what else do I need to do to get the sorts to continuously work in an ajax format?

  • 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-27T21:11:00+00:00Added an answer on May 27, 2026 at 9:11 pm

    I think you can simplify your code a bit by delegating events:

    $(document).ready(function() {
        // cache mydiv location
        var $mydiv = $("##mydiv");
        $mydiv.on("click",".sortLink",function(e){
            e.preventDefault();
            // split on ? instead to avoid an IE issue on dynaimcally created anchors.
            var recorddata = $(this).attr("href").split("?")[1]; //trim '?' char
            $.ajax({
                type: "GET",
                url: "generateInfo.cfc?method=getEmailData",
                data: recorddata,
                dataType: "html",
                success: function(message) {
                    $mydiv.html(message);
                }
            });
        }).on("click",".loadLink",function(e){
            e.preventDefault();
            // split on ? instead to avoid an IE issue on dynaimcally created anchors.
            var recorddata = $(this).attr("href").split("?")[1];
            var curElement = $(this);
            if ($(this).attr("id") != "disabledLink") {
                $.ajax({
                    type: "GET",
                    url: "generateInfo.cfc?method=getEmailData",
                    data: recorddata,
                    dataType: "html",
                    success: function(message) {
                        $('##pageLinks').children('a').each(function() {
                            if ($(this).attr("id") == "disabledLink") {
                                $(this).removeAttr("disabled");
                                $(this).removeAttr("id");
                            }
                        });
                        curElement.attr("disabled", "disabled");
                        curElement.attr("id", "disabledLink");
                        $mydiv.html(message);
                    }
                });
            }
        });
    
        // load the first page of records upon initial load.
        $("##mydiv").load("generateInfo.cfc?method=getEmailData");
    
    });
    

    This will ensure that your events are always bound on ajax-built DOM nodes.

    As far as the change I made to the recorddata, in IE, if you dynamically add an anchor tag after load, it will contain the full path to the location rather than the path you gave it. So, if you set the href as ?foo=bar, it will be http://mydomain.com?foo=bar

    Change from comment:

    }).on("click",".loadLink",function(e){
    

    becomes

    });
    $(".loadLink").on("click",function(e){
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wondering how the HttpContext is maintained given that the request-response nature of
I am developing a small, internal-use only web application. Given its simple nature and
I'm currently trying to find out if there is a way to allow our
Logically speaking, given the nature of floating point values, the maximum and minimum representable
I'm working on a project where user's submit data and then it is put
Plugin x.y.z is supposed to run on top of a Java project and generate
I'm working on a project and have a problem that I believe can be
Given different data sources I would like to find out all foreign keys inside
Given a specific DateTime value, how do I display relative time, like: 2 hours
Given a Python object of any kind, is there an easy way to get

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.