最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to refresh dialog in dojo - Stack Overflow

programmeradmin1浏览0评论

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
Add a ment  | 

2 Answers 2

Reset to default 4

Usually, 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.

发布评论

评论列表(0)

  1. 暂无评论