Dojo and ajax - initializing html with the dojoType attr
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?
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
精彩评论