我正在使用Dojo工具包構建SRS,以幫助我學習Dojo Toolkit和日語。dijit.Editor不顯示日文字符
對於那些不知道SRS的人基本上是一個閃存卡系統。
因此,我有一個側欄,可以選擇一副紙牌進行審閱,當我從列表中點擊一副套牌時,它會在TabContainer
中打開一個新選項卡,其中包含兩個ContentPane
s。
一個ContentPane
包含DataGrid
,它目前使用ItemFileWriteStore
與url
到json
文件。
的json
文件包含每個項目possesing的id
,question
和answer
爲DataGrid
的項目。
id
目前只是一個integer
值,並且question
和answer
都包含日語字符串。
這個想法是,當單擊DataGrid
中的一行時,在包含DataGrid
的那個下面的ContentPane
應該將其內容替換爲dijit.Editor
。
ContentPane
被替換之前的原始內容只是一個簡單的字符串,說Click on the rows in the grid above to edit a card's details
。
我以編程的方式創建了dijit.Editor
,並且一切正常,直到我試圖從DataGrid
的行中爲它提供一個日文字符串。
這是我的JavaScript它得到了DataGrid
行的信息,並創建了dijit.Editor
:
(grid
是DataGrid
對象和card_details
是的ContentPane
的id
)
dojo.connect(grid, 'onRowClick', function(e) {
var id = grid.getItem(e.rowIndex).id;
var question = grid.getItem(e.rowIndex).question;
var answer = grid.getItem(e.rowIndex).answer;
dojo.byId('card_details').innerHTML = '';
var editor = new dijit.Editor({
id: 'editor',
value: question
}, dojo.byId('card_details'));
});
上面的代碼創建的dijit.Editor
在ContentPane
中,但沒有填充存儲在question
變量中的值(我記錄並提醒了變量,它確實包含預期值)。
但是,如果我用文字字符串如My String
替換該變量,或者甚至像反亂者
這樣的日語,它的工作原理就很好。
它甚至如果我更換:var question = grid.getItem(e.rowIndex).question;
有:var question = '反亂者';
有誰知道爲什麼它不會使用它時已分配它的值通過grid.getItem(e.rowIndex).question
的question
變量時工作?
對於Dojo Toolkit,我仍然是一個初學者,所以我相信它肯定是顯而易見的。
任何幫助,將不勝感激!