Stopping google translate from translating datepicker
Asked Answered
L

1

6

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?

Lymphosarcoma answered 16/6, 2013 at 5:6 Comment(0)
P
21

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/

Posting answered 16/6, 2013 at 5:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.