`

s:doubleselect 与 sx:div

阅读更多

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

 

 

 

 

Attribute Default Value Description
parseContent true When 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.
separateScripts true When 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.
executeScripts false When 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”。

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics