s:doubleselect 与 sx:div

s:doubleselect 与 sx:div 结合使用,某些属性不设置会出现一些莫名的问题。sx:div这个Ajax标签的属性太多,不好好研究下它的属性而使用它会出现许多莫名的问题,其中列表选项无法联动就是比较难缠的问题。后来通过搜索发现此标签的“separateScripts”属性是其引起问题的主因!官方文档上说明了会影响Ajax标签的几个属性,如下:

 

 

 

 

AttributeDefault ValueDescription
parseContenttrueWhen true, Dojo will parse the response into an XHTML Document Object and traverse the nodes searching for Dojo Widget markup. The parse and traversal is performed prior to inserting the nodes into the DOM. This attribute must be enabled to nest Dojo widgets (dojo tags) within responses. There's significant processing involved to create and parse the document so switch this feature off when not required. Note also that the response must be valid XHTML for cross-browser support and widgets must have unique IDs.
separateScriptstrueWhen true, Dojo will extract the <script> tags from the response, concatenate the extracted code into one block, create a new Function whose body is the extracted code and immediately invoke the function. The invocation is performed after the DOM has been updated with the XHTML. The function is executed within the scope of the widget (that is, the this variable points to the widget instance).
When false, Dojo will extract the <script> tags from the response, concatenate the extracted code into one block and:
*in IE: invoke window.execScript() on the code
*in other browsers: create a <script> node containing the code and insert that node into the DOM
This invocation occurs after the DOM has been updated with the XHTML. Note that scripts may not be executed if it is not valid to create a <script> node in the DOM at the destination.
executeScriptsfalseWhen true, Dojo will extract code from the <script> tags from the response and execute it based on the separateScripts value.
When false, the XHTML response is inserted into the DOM and <script> nodes are ignored.

 

 

我们主要看 separateScripts ,其描述文字的主要大意是,如果此属性设置为“true”,Dojo会将从response中提取<script> 标签内的代码并组合到一个新建的函数,并立即调用。此属性默认就是“true”,这不是我们想要的,因此把此它设置为“false”,问题解决。

 

 

还需要注意的是executeScripts这个属性设置不好也会出现Javascript无法运行的问题,比如A.jsp文件内的标签sx:div异步引入B.html文件,此文件有一段Javascript代码,比如:<script>alert("弹出信息");<script>,若要此代码正常执行,则executeScripts属性必须设置为“true”。

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值