I am new to dojo(infact coding) and am struggling with setting the locale on the dojo editor. I have a scenario where in JSP1: language value is input and the value is submitted as a hidden variable JSP2: DOJo editor is displayed based on the language.I would like to set the locale of the dojo editor. I am trying to retrieve the hidden variable value开发者_如何学运维 but the editor always shows with "en" locale. I have done "View Source" on the page and the hidden variable is populated with the correct parameter.
<head>
<script type="text/javascript">
var editorLang = '';
var currentLocale = '${param.selected_lang}' ; //is an issue ,
//cant see the lang getting retrieved
document.write(currentLocale);
if(currentLocale=='fr'){
editorLang = 'fr';
}else if(currentLocale=='en'){
editorLang = 'en-us';
}
var dojoConfig = {
parseOnLoad: true,
isDebug: false,
locale: editorLang
};
</script>
<style type="text/css">
@import "../script/dojo/dijit/themes/claro/claro.css";
</style>
<script type="text/javascript" src="../script/dojo/dojo/dojo.js">
</script>
<script type="text/javascript">
dojo.require("dijit.Editor");
dojo.require("dijit._editor.plugins.LinkDialog");
dojo.require("dijit._editor.plugins.TextColor");
dojo.require("dijit._editor.plugins.AlwaysShowToolbar");
dojo.require("dojo.parser");
</script>
<script>
dojo.addOnLoad(function(){
var editorVal = document.getElementById("editorContents").value;
var lang = document.getElementById("selected_lang").value;
alert(lang); *//here its fine
//can see the lang*
var defaultVal = document.getElementById("DeafultValue").value;
var editor1 = dijit.byId("editor");
editor1.onLoadDeferred.addCallback(function(){
editor1.set("value", defaultVal );
});
});
</script>
<head>
Resolved it by moving the dojo related stuff inside the body (initially was in )
精彩评论