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

The Archive Base Latest Questions

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

For each checkbox on the web page, I replace it with a slider that

  • 0

For each checkbox on the web page, I replace it with a slider that I borrowed from jsfiddle.net/gnQUe/170/

This is done by going through the elements when the document is loaded.

Now the problem is that when more content is loaded via ajax, the new checkboxes are not transformed.

To solve the problem, I used AjaxComplete event to go through all the elements again and replace the checkboxes with sliders.
Now the problem happens that elements that were already replaced, get two sliders. To avoid that I check if the checkbox is hidden and next element is div of class “slider-frame”, then don’t process the re-process the element.

But I have a lot of other such controls as well, and I am presume I am not the only one that has this problem. Is there another easy way around it?

There exists jQuery live/on( http://api.jquery.com/on/ ) event but it requires an event as an argument? whereas I would like to change the look of my controls when they are rendered.

Another example of the same problem is to extend some controls that are loaded via ajax with jQuerys autocomplete plugin.

Is there a better way to accomplish this other than changing some attributes on the element.

To summarize, on document load I would like to process every element in DOM, but when more elements are loaded via ajax then I want to change only the new elements.

  • 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-13T10:34:12+00:00Added an answer on June 13, 2026 at 10:34 am

    I would assume that when the element’s are transformed into a slider, a class is added to them. So just add a not clause.

    $(".MySelector").not(".SomeClassThatSliderAddsToElement").slider({});
    

    So in the case of your code do something like this

    $('.slider-button').not(".sliderloaded").addClass("sliderloaded").toggle(function(){
        $(this).addClass('on').html('YES');
        $('#slider').val(true);
    },function(){
        $(this).removeClass('on').html('NO');
        $('#slider').val(false);
    });
    

    Since you said you do not want to add anything else, how about you change the toggle function to click.

    $(document).on("click", ".slider-button", function(){
       var elem = $(this);
       elem.toggleClass("on");
       var state = elem.hasClass("on");
       elem.text(state?"YES":"NO");
       elem.parent().next().val(state);    
    });
    

    Running fiddle: http://jsfiddle.net/d9uFs/

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

Sidebar

Related Questions

I have a web page that consists of a checkbox (parent) and on this
I have an asp.net web page with a form that contains a series of
I have a checkbox list control on my asp.net web form that I am
I have the following code: function toggleChecked(status) { $(.checkbox).each( function() { $(this).attr(checked,status); }) }
I have this js code: $(#startSearch).live(click, function(event) { $(input:checkbox[name='searchId']:checked).each(function() { var searchId = $(this).val();
I need present a grid-view in the web page, and based on the checkbox
I have an ASP.NET MVC Web Application that interacts with a SQL Server 2008
I'm trying to build a simple Asp.Net website that will list some files. Each
I have an archive page that shows custom posts, each of which has a
I'm loading a web page that has a series of 20+ checkboxes. The page

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.