admin管理员组文章数量:1429844
I have a from in dialog. Everything works percectly, but how can I refresh the values in inputs after save data in db?
Is there a trick to refresh whole form or should I use dialog.reset() when someone hides dialog by pressing Cancel button? If it could be done only by reset() method, so how can I handle event when escape is pressed and the closing-cross (in the top-right corner)
Best regards
I have a from in dialog. Everything works percectly, but how can I refresh the values in inputs after save data in db?
Is there a trick to refresh whole form or should I use dialog.reset() when someone hides dialog by pressing Cancel button? If it could be done only by reset() method, so how can I handle event when escape is pressed and the closing-cross (in the top-right corner)
Best regards
Share Improve this question asked Jan 16, 2012 at 10:33 reizalsreizals 1,3451 gold badge15 silver badges21 bronze badges 1- after the user saves do you want to clear the inputs? – Wayne Baylor Commented Jan 16, 2012 at 20:06
2 Answers
Reset to default 4Usually, if a user closes a dialog, I just destroy the thing and create a new one.
You can use something like this to capture when the user has closed the dialog, and clean it up:
myDialog.connect(myDialog, 'close', function(){myDialog.destroy();});
Note that the fact that you use the connect()
method on the dialog widget means that the connect itself will also be cleaned up when the widget is destroyed.
Nice and neat :)
If you are just looking to clear the form, you can use document.myform.reset()
in the close connect.
A more plete example:
showDia: function(){
myDia = new dijit.Dialog({
title: "Public Reminder",
content: "<center>My incredible dialog content that will change the world</center><br>"+
"<form id='fooBarForm'>"+
"<input type='hidden' name='fooName' id='fooId' value='fooValue'></input>"+
"<select name='barName' style='margin: 3px;' id='barId'>"+
"<option value='barOpt1'>test1</option>"+
"<option value='barOpt2'>test2</option>"+
"</select>"+
"</form>",
style: "width: 320px;"
});
myDia.connect(myDia, 'close', function(){myDia.destroy();});
// OR you can call `reset()` on the fooBarForm instead of `myDia.destroy()`, and when
// you call `showDia()`, check if the dialog already exists and then just call `show()` on
// it
myDia.show();
}
Now, one thing about this is that is does introduce a global name (myDia). But you can easily make that a member of an object and that won't be the case. showDia should also be a member method on an object (ie, not a global function).
Also, this is often done by using a content pane to pull in the content from a URL.
if you create the dialog through your program as new dijit.Dialog(), then when you setting the url you have to set an extra parameter as random number thus every request to server will be treated as new request.......and that is the trick..actually i have succeed this way.
本文标签: javascripthow to refresh dialog in dojoStack Overflow
版权声明:本文标题:javascript - how to refresh dialog in dojo - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745444753a2658611.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论