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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:43:34+00:00 2026-06-10T23:43:34+00:00

I have an unordered list (each list element contains some further markup but this

  • 0

I have an unordered list (each list element contains some further markup but this should not matter) that is constructed (instantiated and appended) from an AJAX call to the DB. I want to clear the list before any following AJAX call results are made.

$('#list').empty()

Does not work for some reason (I have tried many alternative schema with .remove() and .not() as well with no success). I know I am targeting the items correctly because I can change the css etc.
Best I can do is delete an element by class from within each li by:

$('list li .class').remove()

Am I doing something fundamentally wrong here?

Btw the list elements are being rendered using Mustache but that should not matter as once rendered it is simply HTML markup, or am I wrong here too?

Thanks for any help.


[EDIT]
Ok so no luck getting any decent AJAX response on jsfiddle so here is the essence AJAX function call:

function loadResults() {
$.ajax({
    'type' : 'POST',
    'url' : '/lib/ajax.php',
    'data' :    {
            'data1' : $('#data1').text(),
            'data2' : $('#data2').text(),
            'data3' : $('#data3').text()
            },
    'success' : function(data) {

           data = JSON.parse(data);

           // remove old results and add new results iteratively
           $('#results ul').empty();

           $.each(data, function(i, elem) {

              // Load the template
              $.get('/views/default/templates/elem_tpl.html', function(t) {
                       tmpl = t;
                   });

               $(document).ajaxStop(function() {
                   var template = Mustache.render(tmpl, elem);
                   $('#results ul').append(template);
               });
            });
        }
});

}

The HTML is literally just a basic list for testing purposes:

<div id="results">
     <ul>
     </ul>
</div>

If that helps any.

  • 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-10T23:43:35+00:00Added an answer on June 10, 2026 at 11:43 pm

    Not exactly the answer but to anyone who encounters a similar issue when using Mustache for some dynamic templating my solution was to switch to underscore.js for the client side templates.

    You do not need to modify any of your templates (mine are in external files so this saved time) if you just add the following prior to calling the template(s):

    _.templateSettings = {
    interpolate : /\{\{(.+?)\}\}/g
    };
    

    Worked perfectly first time. I don’t know what Mustache was doing to confuse jQuery I will try look into this when I have more time on my hands.

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

Sidebar

Related Questions

I have an unordered list and each list element contains a photo and a
I have an unordered list that displays like this: http://jsfiddle.net/spryno724/XYBja/ . Notice how the
I have a unordered list, with each list element containing two spans (say span
I have a un-ordered list of links, each of which contains some text and
I have an unordered list that is a child in a smaller parent div
I'm going to have a unordered list ( <UL> ) of items. Each item
I have an unordered list I'm using for a menu. Each item has a
I have an unordered list with five list items, each with a link inside
I have an unordered list with five list items, each with a link inside
I have an unordered list with no list items. I get some information from

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.