我有一个自定义的dojo小部件(提醒),我想在一个事件上重新加载(点击小部件上的添加按钮,对话框将打开,我将填写提醒数据,然后点击提交。点击提交按钮小部件应该重新加载我填写对话框的数据。
<body class="claro teller">
<form name="tellerForm">
<input type="hidden" name="expldQryStr" id="expldQryStr">
<input type="hidden" name="actionCode" id="actionCode">
</form>
<div class="row">
<div data-dojo-type="MyCashBalanceWidget.MyCashBalance" data-dojo-props="title:'Our Cash Balance Widget',data:CashBalData,data1:invtData"></div>
<div data-dojo-type="MyFrequentTasksWidget.MyFrequentTasks" data-dojo-props="pageName:'TellerLandingPage',title:'Our Some Widget',data:freqTskData"></div>
<div data-dojo-type="PendingTransactionWidget.PendingTransaction" data-dojo-props="title:'Pending Transaction Widget',data:pndTrnData,data1:pndVrfData"></div>
<div id="remWdgt" data-dojo-type="MyRemindersWidget.MyReminders" data-dojo-props="pageName:'TellerLandingPage',title:'My Reminders Widget',data:rmndrData"></div>
<div data-dojo-type="MyAppsWidget.MyApps" data-dojo-props="pageName:'TellerLandingPage',title:'My Apps Widget'"></div>
<div data-dojo-type="MyActivityWidget.MyActivity" data-dojo-props="pageName:'TellerLandingPage',title:'My Activity Widget',data:analData"></div>
</div>
<div data-dojo-type="TellerLandingPageGridWidget.TellerLandingPageGrid" data-dojo-props="title:'Teller Landing grid',data:lastTrans">
</div>
<script>
//including all the custom widgets
require(
[
"dojo/parser",
"CommonWidgets/MyFrequentTasksWidget",
"Widgets/MyCashBalanceWidget",
"Widgets/PendingTransactionWidget",
"CommonWidgets/MyRemindersWidget",
"CommonWidgets/MyAppsWidget",
"CommonWidgets/MyActivityWidget",
"Widgets/TellerLandingPageGridWidget"
],
function( parser) {
parser.parse();
});
</script>
</body>
</html>
答案 0 :(得分:0)
我不确定你的完整情况。但在这种情况下,你有两种方式: - 1)将事件监听器添加到您的自定义窗口小部件,它将自行侦听和修改 2)重新创建窗口小部件,使用新值传递它的构造函数。
答案 1 :(得分:0)
您的问题很不清楚,但从它的声音来看,如果提交对话框中的表单,您只想设置特定DOM节点的innerHTML
。没有理由为此重新加载小部件,您可以只在对话框表单的submit事件中添加一个事件处理程序,并使用它来设置小部件中特定元素的innerHTML
。 / p>
首先,您需要在对话框中添加onLoad
事件侦听器,以便准确知道何时将事件处理程序添加到表单中:
postCreate: function() {
this.myDialog = new Dialog();
this.myDialog.on("load", lang.hitch(this, this.loadDialog));
this.myDialog.set("content", "<div><form><input type='text' /><button type='submit'>Submit</button></div>");
},
这将在您的小部件上调用函数loadDialog
,如下所示:
loadDialog: function() {
var vm = this;
query("form", this.myDialog.domNode).on("submit", function(evt) {
evt.preventDefault();
vm.myLabel.innerHTML = query("input", this).val();
vm.myDialog.hide();
});
},
当提交对话框中的表单时,此函数使用dojo/query
和dojo/NodeList-manipulate
来获取表单字段值。然后,该值用于更改我赋予属性myLabel
的窗口小部件上的data-dojo-attach-point="myLabel"
元素,以便可以在窗口小部件代码中轻松访问该元素:
templateString: "<div><label data-dojo-attach-point='myLabel'></label><button data-dojo-attach-event='onClick: openDialog'>Add</button></div>",