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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:08:34+00:00 2026-05-23T03:08:34+00:00

i’ve been stuck in this loop for a while. Basically i have a slider

  • 0

i’ve been stuck in this loop for a while. Basically i have a slider that performs some action when the slider values changes. First thing i do is make a check, and if that check doesn’t pass, i need to reset the value of the slider. But resetting the value of the slider changes it!And so i’m stuck. Here is my code:

Slider:

    $(element).slider({
        min: 0,
        max: 10,
        step: 1,
        value: initialValue,
        animate: false,
        slide: _updateOnSlide,
        change: _performAction
    }); 

var _performAction = function(evt, ui){
    if (CT.travel.atLeastOneStepPresent()){
        var id = $(this).attr("id");

        _updateOnSlide(evt, ui);

        if (id != "travelTime"){//se è il tempo non aggiorno


            CT.makeQuery();

        }
        CT.timeline.update();
    }else{
        alert("you can't do this");
        $(this).slider("value", 0);
        _updateOnSlide(evt, ui);
    }
}

The problem is that $(this).slider("value", 0); triggers another change event!
Anyone knows how to solve this?

I need to use the change function because i’m changing the values of the slider by clicking buttons, not by sliding it.

EDIT – evt.originalEvent is always undefined for me (if i cosole.log it like this console.log(evt.originalEvent)) but for some strange reason i see it if i console.dir it. But unfortunately it doesn’t solve the problem, i add here the part of my code that vhanges the value of the slider (pardon me i forgot to do that earlier)

            $('.plus').click(function(event){
                var sliderCurrentValue = $( this ).next().slider( "value" );
                $(this).next().slider( "value", sliderCurrentValue + 1 );
            });

As you can see, the value is changed programmatically the first time and so the check on the evt.originalEvent would be useless anyway.

EDIT 2 – i’ve found a way out of this but i hope there is a better way:

        alert("you can't do this");
                    //destroy the slider
        $(this).slider("destroy");
                    // recreate the slider
        _makeSelector(this);

I think it could also work if i just removed the function binded to the “change” event and reset the value, but i hope there is a better way of doing this!

  • 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-23T03:08:35+00:00Added an answer on May 23, 2026 at 3:08 am

    Check for the existence of evt.originalEvent.

    If it’s there, the change was initiated by the user using its own controls. If it’s not, it indicates a program initiated change.

    EDIT – probably the easiest solution is to temporarily .unbind() the change handler before you reset the slider, and then .bind it again immediately afterwards.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I'm looking for suggestions for debugging... If you view this site in Firefox or
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string

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.