dijit.Editor doesn't display Japanese characters

General Tech Learning Aids/Tools 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Learning Aids/Tools related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I am using the Dojo Toolkit to build an SRS to both aid in my learning of both the Dojo Toolkit and the Japanese language.

For those of your who don't know an SRS is basically a flash card system.

So, I have a side bar where I can choose a deck of cards to review and when I click on a deck from the list it opens up a new tab in a TabContainer which contains two ContentPanes.

One ContentPane contains a DataGrid which currently uses an ItemFileWriteStore with a url to a json file.

The json file contains the items for the DataGrid with each item possesing an idquestion and answer.

The id is currently just an integer value and the question and answer both contain Japanese strings.

The idea is that when a row in the DataGrid is clicked, the ContentPane below the one containing the DataGrid should have it's contents replaced with a dijit.Editor.

The original contents of the ContentPane before they are replaced is just a simple string saying Click on the rows in the grid above to edit a card's details.

I am creating the dijit.Editor programmatically and everything works well until I try to give it a Japanese string from the DataGrid's row.

This is my JavaScript which gets the DataGrid row's information and creates the dijit.Editor:

(grid is the DataGrid object and card_details is the id of the ContentPane)

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'));
});

The code above creates the dijit.Editor in the ContentPane but doesn't fill it with the value stored in the question variable (I have logged and alerted the variable and it does contain the expected value).

However if I replace the variable with a literal string like My String or even something in Japanese like 反乱者 it works just fine.

It even works if I replace: var question = grid.getItem(e.rowIndex).question; with: var question = '反乱者';

Does anybody know why it won't work when using the question variable when it has been assigned it's value via grid.getItem(e.rowIndex).question?

I am still a beginner when it comes to Dojo Toolkit so I'm sure it must be something obvious.

Any help would be appreciated!

profilepic.png
manpreet 2 years ago

I have found the answer to my question now.

It turns out I just needed to change:

var question = grid.getItem(e.rowIndex).question;

to:

var question = grid.store.getValue(grid.getItem(e.rowIndex), 'question');

0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.