2015-02-24 38 views
0

我試圖沒有成功禁用HTML5日期輸入上的滾動。
此輸入有一個webshim回退,這導致我的JS與Chrome,但不是Firefox。Firefox:禁用HTML5日期輸入上的滾動具有webshim後備

$('.input-date input').on('mousewheel', function (event) { 
 
    event.preventDefault(); 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/webshim/1.15.6/dev/polyfiller.js"></script> 
 

 
<script type="text/javascript"> 
 
    webshims.cfg.no$Switch = true; 
 
    webshim.setOptions({ 
 
    'forms-ext': { 
 
     widgets: { 
 
     calculateWidth: false 
 
     } 
 
    } 
 
    }); 
 
    webshim.polyfill('forms forms-ext'); 
 
</script> 
 

 
<form> 
 
    <div class="input-date"> 
 
    <input type="date" value="2015-02-24"> 
 
    </div> 
 
</form>

有誰曾經面臨過這樣的問題?

回答

0

我有機會與webshim的作者討論這個問題,並發現有一個選項可用來避免這種問題:noSpinbtn

這樣,代碼將是這樣的:

$('.input-date input').on('mousewheel', function (event) { 
 
    event.preventDefault(); 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/webshim/1.15.6/dev/polyfiller.js"></script> 
 

 
<script type="text/javascript"> 
 
    webshims.cfg.no$Switch = true; 
 
    webshim.setOptions({ 
 
    'forms-ext': { 
 
     widgets: { 
 
     calculateWidth: false 
 
     }, 
 
     date: { 
 
     noSpinbtn: true 
 
     } 
 
    } 
 
    }); 
 
    webshim.polyfill('forms forms-ext'); 
 
</script> 
 

 
<form> 
 
    <div class="input-date"> 
 
    <input type="date" value="2015-02-24"> 
 
    </div> 
 
</form>

相關問題