Link to home
Start Free TrialLog in
Avatar of derrida
derrida

asked on

how to refresh a jquery UI dialog after a form submitted?

Hi
i have  a jquery ui dialog that open with a table of data from the database.
i also have a link that open another UI dialog with a form to add an item.

right now, when i press the submit button of the form i refresh the whole page and  that is it. what i want is to refresh the first dialog when the submit button is pressed.

so when i add an item and press the submit: the form dialog is cloased and the dialog with the data display the refreshed data.

i add my ajax code for the form submition.

    $("#devidersend").live('click',function(e){
        e.preventDefault();
          var devidertitle = $("#devidername").val();
          var devidermenutype =  $("select#devidermenutype option:selected").val();
          var deviderlang = $("select#deviderlang option:selected").val();
          // $("form#form-menu p.msg").remove();
          //triger a click the current menu group.
          $.ajax({
            type: 'POST',
            url: '/cms/addDevider/',
            data:{
                devidertitle:devidertitle,
                devidermenutype:devidermenutype,
                deviderlang:deviderlang
            },
            datatype: 'json',
            success: function(data){
                var theData = JSON.parse(data);
                
                if(theData.type == 'errors'){     
                    $("form#devideradding").prepend("<ul class='formalerts'>");
                    $.each(theData.message, function(key, value) { 		 		
                        $("form#devideradding ul.formalerts").append("<li> "  + value + "</li>");
                    });
                    $("form#devideradding ul.formalerts").append("</ul>");
                }else if(theData.type == 'missings'){
                    $("form#devideradding").prepend("<ul class='formalerts'>");
                    $.each(theData.message, function(key, value) { 		 		
                        $("form#devideradding  ul.formalerts").append("<li>" +emptyfield+ ": "  + value + "</li>");
                    });
                    $("form#devideradding ul.formalerts").append("</ul>");
                }else {
                   window.location.href = '/';
                    $('div#adddevider').delay(5000).queue(function(){
                        $('div#adddevider').dialog("close");
                    });
                   
                }
            },
                        beforeSend: function() {
                           $('form#devideradding').prepend("<p class='loadit' ></p>");
                        },
                        complete: function(){
                            $("p.loadit").fadeOut();
                        }
        });
        return false;
    });

Open in new window



how can i get this to work?

best regards
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

window.location.href = '/';
Will reload the page. Why do you do that?
Avatar of derrida
derrida

ASKER

because as it stand now i have no idea how to refresh the dialog UI. once i`ll be able to do that i will not reload the page.
Do you have a page somewhere?
Avatar of derrida

ASKER

hi
no its on my locqal machine.
but the issue is : where right now i do
window.location.href = '/';
to write a code that refresh the specific dialog.
With the code provided I cannot help you solve your issue - I do not know what you mean by refreshing the UI dialog since I do not see it opened
Avatar of derrida

ASKER

hi
think about a simple CRUD . lets say: user management.
when i press a "manage users" a jquery UI dialog is opened with a table of all the users and a link to add a new user. when this link is pressed a new jquery UI dialog is opened with a form for adding a user.
when this form is submitted i close the form dialog and i want to refresh the table of users in the table dialog.
So refresh dialog or table?
Can you make some screen shots?
Avatar of derrida

ASKER

well the table since i want the new data to appear once i added a new content.

i attach the imagesUser generated image User generated image
what i need is that when i press the submit button in the form: the form dialog will close and the data in the first dialog will be updated.
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of derrida

ASKER

had no idea i can fake a click
thanks