we're using Kendo UI with the MVVM implementation for on of our web applications (SPA) and I have a question regarding the list view.
To provide the option to change the language on the fly, we're using a script library that basically looks for html-elements with a specific attributes replaces their text with a string based on the value of the attribute and the current culture you selected. To trigger this, a function needs to be called that translates the current document.
Now this wasn't problem so far, since I always found the right places to trigger the translation, but now I'm at a loss with the ListView templates. Both the data and the edit template have such tags that need to translated (<dl> tags to be specific). Basically what needs to happen is the following:
- Site loads -> ListView loads -> Template is loaded and filled via a dataSource -> Translate the Template after loading finished
- Click on Edit or Add -> ListView loads EditTemplate -> Translate the EditTemplate
- Click Save in Edit -> ListView loads Template -> Translate the Template
- Click on Cancel in Edit -> ListView loads Template -> Translate the Template
Cases 1-3 are no problem.
- Hook into the dataBound event, Template is loaded, start translation
- Hook into the edit event, EditTemplate is loaded, start translaton
- Hook into the save event, Template is loaded, start translation
- Now I know can hook to the cancel event but here's the problem: Hook into the cancel event, Template is not loaded, translation starts, Template is loaded
The cancel event, unlike the other events, fires before the template is loaded. So the translation runs, but at this point the Template is not loaded and therefore not translated.
Is there any way to do this? The best option (which I could not find on the internetz) would be to hook into the "load template" event if there is one or simply any other possibility to call this translation after the template loaded.
I tried many other ways and many other events - my best option was to bind to the "DOMSubTreeModified" event, but that backfires (literally) because the translation algorithm also modifies the subtree :/
Any solution would be appreciated.