[英]Alloy-Script/Javascript in dynamically loaded JSP
我目前正在使用Ajax調用動態加載各種JSP。 但是,一旦加載了JSP,其中包含的所有Javascript都不起作用。 我認為這是因為內部的腳本尚未解析。
為此,我找到了模塊“ aui-parse-content”,根據其描述,該模塊應該能夠解析所包含的腳本。
ParseContent實用程序-解析節點的內容,以便該節點中包含的所有javascript將根據其出現的順序執行。
但是,我無法使其正常工作。 這是我的AUI:Script供參考。
<portlet:resourceURL var="viewContentURL">
<portlet:param name="jsp" value="<%= tmp %>"/>
</portlet:resourceURL>
<div id="<portlet:namespace />jspcontent"></div>
<aui:script use="aui-base, aui-io-request,aui-parse-content, aui-node">
var url = '<%= viewContentURL.toString() %>';
AUI().io.request(
url,
{
on:{
success: function(){
var message = this.get('responseData');
//alert(message);
AUI().one('#<portlet:namespace />jspcontent').html(message);
AUI().one('#<portlet:namespace />jspcontent').plug(AUI().Plugin.ParseContent);
},
failure: function(){
alert("An error occured");
}
}
}
);
</aui:script>
先感謝您!
-約翰
編輯:由於我前一段時間找到了一個修復程序,其他人可能有相同的問題,這就是我如何使aui-parse-content工作的:
on:{
success: function(){
var message = this.get('responseData');
var tmp = A.one('#<portlet:namespace />jspcontent');
tmp.html(message);
tmp.plug(A.Plugin.ParseContent);
tmp.ParseContent.parseContent(message);
},
}
我前一陣子找到了一個修復程序,其他人可能也遇到了同樣的問題,這就是我使aui-parse-content工作的方式:
on:{
success: function(){
var message = this.get('responseData');
var tmp = A.one('#<portlet:namespace />jspcontent');
tmp.html(message);
tmp.plug(A.Plugin.ParseContent);
tmp.ParseContent.parseContent(message);
},
}
我還修改了原始帖子以反映我的發現
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.