1

I have 2 pages: index.php and form1.php. In my index.php I have a button which has function to load content of form1.php on div:

$("#btnLoadContent").button().click(function(){
$("#divcontent").empty().load("form1.php")});

On form1.php y have a form and a button named btnSend. On index i'm using this:

$("#btnSend").button();

but when loaded, this button doesn't have the style or functionality of the implemented script. And I haven't realized why.

1
  • the code doesn't seem to be correct, try posting the full corrected code for more accurancy Commented Nov 30, 2011 at 16:43

3 Answers 3

1

You probably need to use the live function in jQuery.

Also, if the ajax loaded content is within an iframe, the styles need to be called from within the loaded site again.

Sign up to request clarification or add additional context in comments.

Comments

1

I think that the .button() will have already been executed when index.php loads. It will not execute again after form1.php has loaded. The .load() function has a callback parameter which will execute after the content has loaded. You should add the $("#btnSend").button() to that callback function instead.

For example:

$("#divcontent").empty().load('form1.php', function(response, status, xhr) {
    $("#btnSend").button();
});

Comments

0

I Found the answer.

Just tried this code

$("#btnLoadContent").button().click(function(){
    $.ajax({
        url:"form1.php",
        success:function(data){
            $("#divcontent").empty().append(data);
            $("#btnSend").button();
        }
    });
});

Comments

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.