Skip to content

Slider: Fix to restrict handle values when set programmatically. #1479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

dekajp
Copy link
Contributor

@dekajp dekajp commented Mar 10, 2015

Fixes #3762 - Slider: handles not restricted properly when set programmatically

ui/slider.js Outdated
@@ -157,6 +158,48 @@ return $.widget( "ui.slider", $.ui.mouse, {
}
},

_cleanValues: function( index, newValue ) {
var i = 0, values ;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uninitialized variables go at the top:

var values,
    i = 0;

@scottgonzalez
Copy link
Member

There are some spacing issues and I didn't do a full review because it looks like this still needs some changes to how it works.

@jzaefferer jzaefferer added this to the land-before-esformatter milestone Mar 13, 2015
@dekajp dekajp force-pushed the ticket_3762_V2 branch 2 times, most recently from 8fd5751 to 8c75382 Compare March 24, 2015 10:02
@jzaefferer
Copy link
Member

@dekajp please comment on your PRs after you push an update, since the push itself has no notification.

@scottgonzalez there's a new commit since yesterday

ui/slider.js Outdated
@@ -422,6 +465,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
this._refreshValue();
} else {
if ( this.options.values && this.options.values.length ) {
this.options.values = this._cleanValues( this.options.values );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the values being cleaned during a get?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change this and move _cleanValues to create

@scottgonzalez
Copy link
Member

Maybe we should start with just a set of tests so that we can agree the correct behavior is being tested.

@dekajp
Copy link
Contributor Author

dekajp commented Apr 1, 2015

do you want me to add/modify the unit test cases ?

@dekajp dekajp force-pushed the ticket_3762_V2 branch 3 times, most recently from 7c921d3 to 296e454 Compare April 2, 2015 03:12
@dekajp
Copy link
Contributor Author

dekajp commented Apr 2, 2015

From http://bugs.jqueryui.com/ticket/3762#comment:31

  1. Restricting the value of a handle based on other handles only applies with range: true and therefore also only applies when exactly two handles exist.
  2. When setting both values at the same time, either via .values( array ), .option( "values", array ), or initialization,
    1. the first handle can be any value between min and max and
    2. the second handle must be between the first handle and max.
  3. When setting a single handle, it is restricted by the min, max, and existing value of the other handle.

@dekajp
Copy link
Contributor Author

dekajp commented Apr 2, 2015

@scottgonzalez , i will send a new PR on this.

element.slider( "values", 1, 75 );
equal( element.slider( "values", 1 ), 75, "Values (index,value) - set second handle" );

element.slider( "values", [ 50, 75 ] );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is effectively a no-op. Why is it here?

@scottgonzalez
Copy link
Member

@dekajp What's the status of this?

@dekajp
Copy link
Contributor Author

dekajp commented May 6, 2015

@scottgonzalez last 3 weeks i was busy with relocation. i think this weekend i will be able to get back on this

@scottgonzalez
Copy link
Member

Thanks. Hope the move went well.

@dekajp dekajp force-pushed the ticket_3762_V2 branch 2 times, most recently from 7dd5ce8 to b65c3bb Compare May 9, 2015 04:27
@dekajp
Copy link
Contributor Author

dekajp commented May 9, 2015

@scottgonzalez yeah move went all , everyone happy in family :) with more space . I rebased commits .

equal( element.slider( "values", 0 ), 10, "Values (index,value) - 1st handle restricted properly, against min" );

element.slider( "values", 0, 90 );
equal( element.slider( "values", 0 ), element.slider( "values", 1 ), "Values (index,value) - 1st handle restricted properly, against 2nd handle" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that you're trying to show that the handles are matching, but I'd prefer an explicit value for the expected value.

@jzaefferer jzaefferer removed this from the land-before-esformatter milestone Oct 17, 2015
@jzaefferer
Copy link
Member

@dekajp would you be available to rebase this and update the implementation?

Fixes #3762 - Slider: handles not restricted properly when set programmatically
@dekajp
Copy link
Contributor Author

dekajp commented Oct 21, 2015

@jzaefferer i rebased by commit. I will look into update the implementation

@sameer05k21a0440
Copy link

I have dynamic multiple input and dynamic slider handle so when on change input text value need to set slider value but I can't set slider handle check below code .

 $(this).parents("tr").find('input[name="assesmentScore"]').change( function (event) {
	   					 var textValue = $(this).parents("tr").find('input[name="assesmentScore"]').val();
$("#bonusScore", $(this)).slider('value',textValue);    //here need to add dynamic slide how ? 
	   					handle.text(textValue); //Can't set corresponding text
});

Note :Please let me if needed full code.
Thanks

@dmethvin
Copy link
Member

dmethvin commented Aug 1, 2019

Closing as a stale branch.

@dmethvin dmethvin closed this Aug 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

7 participants