Dojo timing issue with dijit/registry and dojo/domReady

∥☆過路亽.° 提交于 2019-12-14 02:59:12

问题


I am working on a one-page application in Dojo which submits forms via ajax and returns parses the return value before rendering the page. When I go about this I end up with a timing error.

When the following code is included via a script tag, it logs undefined:

require(["dijit/registry", 'dojo/domReady!'], function(registry){ console.log(registry.byId('my-id')) });

When I paste it in the console, I get the expected dijit widget.

I suspect that the problem is that this is firing before the page is rendered. Is there an easy way to ensure that this happens after the current document has been fully parsed and included in the main window?


回答1:


May be you should try, to add Parser and call the Parser.parse() before trying to access the widget.

This is from Dojo documentation

Note that waiting for dojo/domReady! to fire is often not sufficient when working with widgets. Many widgets shouldn’t be initialized or accessed until the following modules load and execute:

  • dojo/uacss
  • dijit/hccss
  • dojo/parser


来源:https://stackoverflow.com/questions/38409151/dojo-timing-issue-with-dijit-registry-and-dojo-domready

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!