Hi everyone,
I'm using Struts 2.1's ajax tags to replace content in a section of my page.
I have this section enclosed in sx:div tags, like so:
<sx:div id="pageContentSection" preload="false" href="%{myUrl}"
listenTopics="/reloadContentSection"
afterNotifyTopics="/contentSectionLoaded" executeScripts="true"
showLoadingText="true" separateScripts="true" indicator="barIndicator">
..
</sx:div>
I change the div content by editing its href with javascript and then
publishing the topic it's listening to:
function reloadContentSection(url){
if(!isAnUrl(url)) return false;
var contentSection = dojo.widget.byId("pageContentSection");
if(contentSection == null) return false;
var origHref = contentSection.href;
contentSection.href = url;
dojo.event.topic.publish('/reloadContentSection', '','');
contentSection.href =origHref;
}
It's working fine otherwise, but I have trouble executing scripts in
returned content. I've experimented with different values of executeScripts
and separateScripts to no effect. I've even tried to include scripts as a
reference to separate javascript library--no better luck there. Even though
scripts I write don't work, a datetimepicker in the same returned content,
done using ajax tags and of course relying on scripts, works perfectly.
When I set separateScripts as false, my scripts are included in generated
DOM source, after some scripts by Matt Cruse, which I assume are directly
related to struts ajax functionality. Of course, being included doesn't mean
that they work.
Right now, I've worked around this problem by including the scripts I need
in the page I'm calling ajax from, and not in returned content. I don't
think this is good design, and won't work if I need to generate scripts
dynamically.
Can any of you tell me what's wrong, or how to fix it?
Jukka