Link to home
Start Free TrialLog in
Avatar of Niall Gallagher
Niall GallagherFlag for Ireland

asked on

Jquery Dialog empty

Hi again,
I have set up a dialog box for updating or creating a new record which opens by a link click
<a href="javascript:getAddRemark()">Add Remark</a>

Open in new window

which calls my script
 function getAddRemark() {
            $.ajax({
                type:"GET",
                url:"/Remarks/Create/" + TreeId,
                success: function(content) {
                    $("#rinput").dialog({modal: true, width:425, resizable: false, title: "Add Remark", dialogClass: "mydialog" });                    
                    $("#irinput").html(content);                   
                    $(".date").datepicker();           

                }                              
            });            
        }

Open in new window


About 8/10 times everything runs perfect but every once in a while the dialog opens and is empty (No labels, textboxes or dropdowns).

I have no idea what is causing it so any help would be highly appreciated.

Thanks
Avatar of Ioannis Paraskevopoulos
Ioannis Paraskevopoulos
Flag of Greece image

Have you tried using
$( document ).ready

Open in new window


$( document ).ready( function getAddRemark() {
            $.ajax({
                type:"GET",
                url:"/Remarks/Create/" + TreeId,
                success: function(content) {
                    $("#rinput").dialog({modal: true, width:425, resizable: false, title: "Add Remark", dialogClass: "mydialog" });                    
                    $("#irinput").html(content);                   
                    $(".date").datepicker();           

                }                              
            });            
        });

Open in new window

Avatar of Niall Gallagher

ASKER

I could be wrong but I don't think $(document).ready comes into this issue as it is a named function and is being called by a button click.

I will try it anyway
When I put in $(document).ready it treats it like I'm trying to call it when the page opens and then fails because there are no parameters yet
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland 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
Chris,
Thanks again, that seems to have done the trick swapping the lines. So far I tried it about 8 times and it was populated every time.

Thanks