Dojo and ajax - initializing html with the dojoType attr

烂漫一生 提交于 2019-12-11 07:15:39

问题


I have a page that has multiple parts of the page loaded via ajax, ie:

<body>
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js" 
     djConfig="parseOnLoad: true, isDebug:true"></script>
  <div class="load_when_user_clicks_here"></div>
  <div class="load_when_user_clicks_here"></div>
  <div class="load_when_user_clicks_here"></div>
</body>

The javascript I have will then replace the innerHTML with html fetched from the server. I've been able to get jquery to work with this and to effect changes on the loaded divs, but I'm having issues with Dojo acting on the div. As of now, Dojo doesn't have an issue when I load the content for the first time. However, when I have a call to reload the content from the server using ajax, the dijit.InLineEditBox below isn't instantiated.

Below is an example of the html fetched from the server:

<script type="text/javascript">
  dojo.require("dijit.InlineEditBox");
  dojo.require("dijit.form.TextBox");
</script>
<span style="margin:30px;" dojoType="dijit.InlineEditBox" 
editor="dijit.form.TextBox">editable</span>

how do I make sure that even on reload, the browser is instantiating the div?


回答1:


I'm not sure I follow the question exactly, but if you are dynamically loading content that has dojoType in it, you will need to manually call dojo.parser.parse() on it after doing an innerHTML assignment. You might also look at using dijit.TitlePane or ContentPane with an href property



来源:https://stackoverflow.com/questions/4485631/dojo-and-ajax-initializing-html-with-the-dojotype-attr

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