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

  • Home
  • SEARCH
  • 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 6600177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:35:17+00:00 2026-05-25T18:35:17+00:00

Maybe its because I have been working all day and I can’t see the

  • 0

Maybe its because I have been working all day and I can’t see the problem. But in the following code the alert only shows the last added value and doesn’t push the value in the array. 🙁

window.sortControl = {
            sortControlPanel: $('div.sortControl'),
            simpleSortCriteriaList: $('div.sortControl .simple'),
            advancedSortCriteriaList: $('div.sortControl .advanced'),
            dropDownExpander: $('div.sortControl .dropDownExpand.primary'),
            dropDownContent: $('div.sortControl .dropdownContent.primary'),
            simpleSortCriteria: $('div.sortControl .sortcriteria.simple a'),
            simpleSortCheckboxes: $('.simple .checkbox'),
            openAdvancedButton: $('.openAdvanced'),
            backtoSimpleButton: $('.backtoSimple'),
            advancedDropdownContent: $('div.sortControl .advanced .dropdownContent'),
            advancedDropdownExpander: $('div.sortControl .advanced .dropDownExpand')
        };

 $.each(sortControl.advancedDropdownContent.parent(), function () {

        var dropdownContent = $(this).find('.dropdownContent');
        var input = $(this).find('input');

        $(this).find('.dropDownExpand').live('click', function (event) {
            sortControl.advancedDropdownContent.not(dropdownContent).hide('fast');
            dropdownContent.toggle('fast');
            event.preventDefault();
        });

        var currentSelectedGroups = [];

        $(this).find('li a').bind('click', function (event) {

            var criteria = $(this).text();
            //if (!currentSelectedGroups.inArray($(this).attr('class'), true)) {
            input.attr('value', criteria);
            currentSelectedGroups.push($(this).attr('class'));

            //}

            dropdownContent.toggle('fast');

            event.preventDefault();
            alert(currentSelectedGroups);
        });

    });

Some of the html:

<div class='sortcriteria advanced'>

                <label>Sort by: </label>
                <div class='controlWrapper'>
                    <input type="text" placeholder='Any' value='Any' class='dropDownExpand'>
                    <span  class='icon dropDownExpand' title='Select property type'></span>
                    <ul class='dropdownContent'>
                        <li><a href='#' class='price'>Price ascending</a></li>
                        <li><a href='#' class='price'>Price descending</a></li>
                        <li><a href='#' class='party'>Party size ascending</a></li>
                        <li><a href='#' class='party'>Party size descending</a></li>
                        <li><a href='#' class='bedrooms'>Number of bedrooms ascending</a></li>
                        <li><a href='#' class='bedrooms'>Number of bedrooms descending</a></li>
                        <li><a href='#' class='star'>Star rating ascending</a></li>
                        <li><a href='#' class='star'>Star rating descending</a></li>                           
                    </ul>
                </div> ...
  1. There are no JavaScript errors.
  2. Content and this script get loaded via ajax
  3. All other statements do what they are supposed to
  • 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-25T18:35:17+00:00Added an answer on May 25, 2026 at 6:35 pm

    You need to move var currentSelectedGroups = []; outside the each loop. You declare it once for every instance – they all work on their own version of the variable because it lives in the local scope of the each function.

    Remember in javascript functions = scope

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

Sidebar

Related Questions

Maybe its because I've been coding around two semesters now, but the major stumbling
I wrote a slideshow plugin, but for some reason maybe because I've been working
Maybe it's because of the dark outside, but I can't get this Position geom_text
I meet a problem yesterday. Maybe it's because it is April 1st... but it
Maybe its a very dumb question but I hope you can give me some
Maybe I'm wrong but for me its not working, I'm trying to do the
I have been working in C# for quite some time but come around this
I have been working on this problem for close to 4 days now. I
Hi I have been searching online for information about this but can't seem to
Im having issues getting this to work, maybe its not even possible? I have

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.