从翻译日期选择器停止谷歌翻译 [英] Stopping google translate from translating datepicker

查看:18
本文介绍了从翻译日期选择器停止谷歌翻译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

这里的addClass":$(".datepicker").datepicker().addClass('notranslate');没有修复它....(谷歌翻译停止工作的日期选择)

出于某种原因,其他代码修复了它:

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

有没有办法在没有 #fix.click 的情况下停止翻译?

解决方案

您的第一行是将 notranslate 类添加到您从中触发日期选择器的输入元素.

日期选择器 UI 元素与输入字段不同,它们会在文档末尾自动创建.您可以使用 jqueryui 类 ui-datepicker(您已经在这样做)找到它们.但是,它们会在您在输入字段上配置日期选择器后立即创建,因此您可以立即在第一行后面添加一行查找自动创建的 ui 元素并向它们添加 notranslate 类(而不是将它放在按钮点击)

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

工作小提琴在这里:http://jsfiddle.net/J5buS/3/>

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?

解决方案

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/

这篇关于从翻译日期选择器停止谷歌翻译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆