我在dojo对话框中使用闭包来防止函数和变量发生冲突。javascript,dojo,在jsp中使用外壳构建对话框
我有一个包含复杂对话框的jsp页面。它主要是在工作。只是一个非常恼人的细节。如果小部件发生变化,我该如何通知处理程序方法?我们希望尽可能多的对话框的java脚本保存在闭包中。
由于弹出窗口出现在多个位置,我希望未来的程序员能够用任何东西替换myVar。有没有一种方法来确定正确放什么的onChange
------ JSP页面-----
var myVar = new MyNewPopupStuff(42);
myVar.contstrucDialog();
......
includeTemplate template="myDialog.jsp"
.....
--------myDialog.jsp----
< script type="text/javascript" src="my.js"/>
.....
< div id="myDialogData" dojotype="dijit.layout.ContentPane" region="right" splitter="true" class="data" style=" width:50%; " > <\/div>
....
-------- my.js文件----
function MyNewPopupStuff(param){ this.contstrucDialog = function() ....... while(more widgets to add){ fieldHolder=dojo.byId("myDialogData" addWidget(widgetName,myDialogData); } addWidget = function(fieldHolder, widgetName){ // need to print the name of the variable in "myVar.bar()" (myVar or what ever it may be) dojo.place(newLabel, fieldHolder); var newField = new dijit.form.ValidationTextBox({ id: "i"+contactTypeId, name: widgetName, value: value, trim: true, **onChange:**??????when the widget is mofied I want to call the below modifyOnChange not some other modify on change I think I want something like myVar.modifyOnChange???? }); } this.modifyOnChange = function() { alert("modified"); } }
谢谢你的帮助。 – 2011-05-27 18:01:59
不客气。 – LHMathies 2011-05-27 19:36:52