开发者

Weird jQuery UI Slider behavior using Page Up/Down

I'm using jQuery UI's slider to update a div containing a number. Dragging or using the left/right keys should only allow the user to choose a number between 1 and 5 (this works as intended). However, if the handle has focus and I use page up/down, I start to get rounded values that are well out of the range of 1-5. Anybody exp开发者_如何学Cerience the same? Thoughts?


Here is the code from the JQuery.UI reopsitory. It looks to me like it may be a bug. You might want to report this here (you'll probably need to register.) BTW the feature was added only seven months ago see here.

   switch ( event.keyCode ) {
        case $.ui.keyCode.HOME:
                newVal = self._valueMin();
                break;
        case $.ui.keyCode.END:
                newVal = self._valueMax();
                break;
        case $.ui.keyCode.PAGE_UP:
                newVal = curVal + ( (self._valueMax() - self._valueMin()) / numPages );
                break;
        case $.ui.keyCode.PAGE_DOWN:
                newVal = curVal - ( (self._valueMax() - self._valueMin()) / numPages );
                break;
        case $.ui.keyCode.UP:
        case $.ui.keyCode.RIGHT:
                if ( curVal === self._valueMax() ) {
                        return;
                }
                newVal = curVal + step;
                break;
        case $.ui.keyCode.DOWN:
        case $.ui.keyCode.LEFT:
                if ( curVal === self._valueMin() ) {
                        return;
                }
                newVal = curVal - step;
                break;
   }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜