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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:56:56+00:00 2026-05-24T20:56:56+00:00

I am using jQuery UI (1.8.16) extensively in my application. I’ve developed a simple

  • 0

I am using jQuery UI (1.8.16) extensively in my application.

I’ve developed a simple function which fetches some json data with an ajax call and converts a DIV in a pager using jQuery UI buttonsets:

<div id="answersPager"></div>

this is the javascript:

BuildAnswersPager: function(selectedPage, totalPages) {
    $("#answersPager").empty();
    if (totalPages > 1) {
    var ctl = [];
    var isChecked = "";
    for (var i = 1; i <= totalPages; i++) {
        if (i === selectedPage) {
        isChecked = " checked='checked'";
        }
        else {
        isChecked = "";
        }
        ctl[i] = "<input class='answersRadioPager' type='radio' value='" + i + "' id='a_page_" + i + "' name='answer_pager' " + isChecked + "/><label for='a_page_" + i + "'>" + i + "</label>";
    }
    $("#answersPager").append(ctl.join(''));
    $("#answersPager").buttonset();
    }
}

I’ve bound each button to a live click event so that every time a user searches for a new term, I reload the window, build a new pager and allow him/her to page the results.

$(".answersRadioPager").live('click', function() {
   // Fetches json data (new page)
});

Everything works fine but I was wondering if I have to destroy the buttonset before I rebuild it (at the moment I just empty it).

Are there any memory issues I must be aware of ?

  • 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-24T20:56:57+00:00Added an answer on May 24, 2026 at 8:56 pm

    Not really. .empty removes all data and handlers attached to any removed markup via jQuery’s internal .cleanData method thereby preventing any memory leaks, so you are quite safe. From the docs:

    To avoid memory leaks, jQuery removes other constructs such as data
    and event handlers from the child elements before removing the
    elements themselves.

    FYI – .html also invokes .cleanData, so using .html('') is equivalent.

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

Sidebar

Related Questions

Using jQuery Ajax to fetch data from local server: it works well with IE8
I have an app that uses ajax (jQuery) quite extensively and when sending JSON
Using jQuery and using the ajax function, what causes it to use the error
Using jQuery, how would you find elements which have a particular style (eg: float:
I am using jQuery ui in a rails application. I want to load content
using jquery ui tabs , when you load a tab in ajax, the tab
I have been developing Web Applications using WAMP stack. I use javascript jQuery extensively
Using jQuery, I make these changes in the DOM: $(document).ready(function() { $('.editable').click(function() { var
Using jQuery 1.7.2 $(function(){ $('#parentElem').mouseenter(function(){ $('.myElem').animate({opacity:1}, 'fast'); }).mouseleave(function(){ $('.myElem').stop().animate{opacity:0}, 'slow'); }); }); In this
I am using: jquery-1.6.2 jquery-ui-1.8.16 collision 1.0.1 ...to build a web-based block painting application.

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.