Problem with JS linked to an Ajax loaded page I am trying to load a form via ajax, the PHP callback that send the data to the Ajax request looks like this : 

function group_form (){

        $node_type = 'group';
        $form_id = $node_type . '_node_form';     
        $node = new stdClass();
        $node-&gt;type = $node_type;
        $node-&gt;title = 'helllooo';
        $node-&gt;language = LANGUAGE_NONE;
        $node-&gt;path = '';
        node_object_prepare($node);
        $return=drupal_get_form($form_id,$node);

    echo render($return);
}


I use to have a problem when using return instead of echo as mentioned in this Q, where the whole page was being sent via Ajax instead of just the form element. However now that i use echo all the script attached to that form do not get reloaded, witch cause problem as my form uses the date module with a jQuery popup calender, and infinite value fields witch need some Drupal JS in order to add multiple values without page reload. 

So i wonder if there is a way around that, if not, anyone has anyidea of what script i should reload on the ajax succes callback in order to have my date module popup calendar and the drupal "Add more" function for infinite value field working ? 

EDIT: I found that using Drupal.attachBehaviors(jQuery('#LoadedContent')); seems to be helping as it brings me from this 



to this , 



though clicking on the "Add another item" Button still reload the page and i end up with this : 

Thanks a bunch for the help.
Have a look at the Ajax Framework. It will make your life way easier. You can probably accomplish everything you're trying to do with out a single line of js.