Mihir
Mihir

Reputation: 2520

Jquery 's dialog strange behaviours for first time only

I am using jQuery dialog in my application. and i am using below function to initialize it.

$searchApplianceDialog = $('#divSearchAppliance')
                            .load('job/searchAppliance.jsp', function() {
                            })
                            .dialog(
                                    {
                                        autoOpen : false,
                                        resizable : false,
                                        draggable : false,
                                        modal : true,
                                        title : ' Search Appliance',
                                        width : 850,
                                        open : function() {
                                            $('#searchApplianceApplianceNumber').focus();

                                            resetApplianceSearch("#applianceList",'Link.do?method=searchJobOrderAppliance&showBlank=true','#frmApplianceSearch');

                                                                                    },
                                        beforeClose : function() {
                                        },
                                        close : function() {
                                            $('#searchApplianceButton').focus();
                                        }
                                    }); // ends search appliance    

when i first open it using

$searchApplianceDialog.dialog('open'); 

it is opened but it creates a problem of positioning itself for first time only . it positions itself correctly in the center of the page with reference to page width but with reference to page height it positioned -20 for y axis and this is only for first time , after every time it gets positioned correctly.

what would be the solution ?

Upvotes: 1

Views: 449

Answers (2)

OQJF
OQJF

Reputation: 1350

Didn't have to much time to test your code, but for the experience since I use it so much. Found the thing likes this maybe. When the dialog there is no data in it and then ajax gets data from server and set it to the dialog, it change the size of dialog, I had this kind of problem. So You should add the open() to the load successful function. and another thing is that you didn't add any code to the close function, so it doesn't actually be removed.

Upvotes: 1

Omar As'hab
Omar As'hab

Reputation: 138

try putting that after

$(document).ready(function(){ 

Upvotes: 2

Related Questions