2010-06-02 62 views
1

我正在使用jQuery UI的滑塊更新包含數字的div。拖動或使用左/右鍵應該只允許用戶選擇一個介於1和5之間的數字(按預期工作)。但是,如果句柄具有焦點並且我使用頁面向上/向下,我開始獲得超出1-5範圍的舍入值。任何人都有相同的經歷?思考?奇怪的jQuery UI滑塊行爲使用Page Up/Down

回答

0

這裏是從JQuery.UI reopsitory的代碼。它看起來像它可能是一個錯誤。您可能想要報告此here(您可能需要註冊。)順便說一下,該功能僅在七個月前添加,請參閱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; 
    }