0

Ok, that title is a mouthful but pretty much says my entire issue.

I have a jQueryUI dialog on my page which is initialised with:

$('#dialog').dialog({
    width: 1024,
    height: 768
});

and the links that open it are initialised wtih:

    // Dialog Link
$('.dialog_link').click(function(){
    $('#dialog').dialog('open');
    return false;
});

So, I use the following code to load a php document into the dialog and display it

$("#openLink123").click(function()
{
 $('#dialog').load("/scripts/dialogContent.php",
  function() {
   $('#dialog').dialog("option","title","Add")
  }
 )
});

The content loads into the dialog and forms etc work just fine, but any javascript I run inside that php document does not. If I close the dialog and reopen it however, all the javascript works.

I'm a bit stumped as to how I can make it so that the javascript runs the first time the dialog loads.

2
  • this code is good the problem is with your other JS code it should be live Commented Feb 20, 2013 at 22:42
  • the JS I have inside dialogContent.php is like <script type='text/javascript'>document.getElementById('addrow').style.display='none';</script> Commented Feb 21, 2013 at 5:31

1 Answer 1

1
$("#openLink123").on('click', function() {
 $('#dialog').load("/scripts/dialogContent.php",function() {
    $('#dialog').dialog("option","title","Add")
  });
});
Sign up to request clarification or add additional context in comments.

2 Comments

changed my code to be like yours, the behaviour remains the same.
also, I've noticed that the callback function does not run the first time

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.