0

我正在寻找一种以编程方式更改 jqm DateBox 插件语言的方法。我在标题部分中包含了语言文件:

<script type="text/javascript" src="../Scripts/jqmDateBox/jqm-datebox.core.min.js"></script>
<script type="text/javascript" src="../Scripts/jqmDateBox/jqm-datebox.mode.flipbox.min.js"></script>
<script type="text/javascript" src="../Scripts/jqmDateBox/jquery.mousewheel.min.js"></script>
<script type="text/javascript" src="../Scripts/jqmDateBox/jquery.mobile.datebox.i18n.de.utf8.js"></script>
<script type="text/javascript" src="../Scripts/jqmDateBox/jquery.mobile.datebox.i18n.en.utf8.js"></script>
<script type="text/javascript" src="../Scripts/jqmDateBox/jquery.mobile.datebox.i18n.fr.utf8.js"></script>
<script type="text/javascript" src="../Scripts/jqmDateBox/jquery.mobile.datebox.i18n.it.utf8.js"></script> 

我尝试使用以下代码片段更改语言(更改JTSage Date and Time Picker plugin for jQueryMobile 中的语言文件):

var x = $.mobile.datebox.prototype.options.lang[newLang];
$(document).find('[data-role=datebox]').each(function () {
    $(this).data('mobileDatebox').options.lang[newLang] = x;
    $(this).data('mobileDatebox').options.useLang = "de";
});

但这给了我以下例外:

JavaScript runtime error: Unable to get property 'options' of undefined or null reference.

如何以编程方式更改 jqm DateBox 插件的语言?

4

1 回答 1

1

I’ve found a way to change the language…</p>

setDateInputOptions($("#dateInput"), "de");
function setDateInputOptions(input, language) {
        input.datebox("option", {
            "mode": "flipbox",
            "useFocus": true,
            "useButton": false,
            "useNewStyle": true,
            "overrideDateFormat": "%d.%m.%Y",
            "overrideDateFieldOrder": ["d", "m", "y"],
            "useLang": language
        });
    }
于 2013-09-03T08:11:02.250 回答