Stopping google translate from translating datepicker

天涯浪子 提交于 2019-12-01 12:26:38

问题


http://jsfiddle.net/tkRaQ/51/

The "addClass" here: $(".datepicker").datepicker().addClass('notranslate'); doesn't fix it.... (google translation stops the selection of dates from working)

For some reason the other code fixes it:

$("#fix").click(function() {
    $('.ui-datepicker').addClass('notranslate');
});

Is there a way of stopping the translation without #fix.click?


回答1:


Your first line is adding the notranslate class to the input element that you're triggering the datepicker from.

The datepicker UI elements are different from the input field, and get created automatically at the end of the document. You can find them with the jqueryui class ui-datepicker (which you're already doing). However, they get created as soon as you configure the datepicker on your input field, so you can immediately follow your first line with a line that finds the automatically-created ui elements and adds the notranslate class to them (instead of putting it on a button click)

$(function() {
    $(".datepicker").datepicker();
    $('.ui-datepicker').addClass('notranslate');
});

Working fiddle is here: http://jsfiddle.net/J5buS/3/



来源:https://stackoverflow.com/questions/17130370/stopping-google-translate-from-translating-datepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!