如何根据隐藏变量值在dojoeditor中设置dojoConfig参数

时间:2011-08-30 07:10:52

标签: javascript dojo rich-text-editor

我是dojo(infact coding)的新手,我正在努力在dojo编辑器上设置语言环境。我有一个场景 输入 JSP1:语言值,并将值作为隐藏变量提交 JSP2:根据语言显示DOJo编辑器。我想设置dojo编辑器的语言环境。我试图检索隐藏的变量值,但编辑器始终显示“en”语言环境。我在页面上完成了“查看源代码”,并使用正确的参数填充隐藏变量。

   <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>

1 个答案:

答案 0 :(得分:0)

通过移动体内的dojo相关内容(最初进入)来解决它