Skip to main content
edited according to question varibales
Source Link
Subharanjan
  • 1.6k
  • 1
  • 17
  • 29

You can re-initialize all the scripts once again inside the AJAX success.

// Fetch the scripts
varscripts $scripts;= '';
if ( $scriptsscripts.length ) $scriptsscripts.detach();
$scriptsscripts = $dataBodyresponse.find('#document-script''script');

// Add the scripts
$scriptsscripts.each(function(){
        var $scriptscript = $jQuery(this), 
                scriptText = $scriptscript.html(), 
                scriptNode = document.createElement('script');
        try {
                // doesn't work on ie...
                scriptNode.appendChild(document.createTextNode(scriptText));
                contentNode.appendChild(scriptNode);
        } catch(e) {
                // IE has funky script nodes
                scriptNode.text = scriptText;
                contentNode.appendChild(scriptNode);
        }
        if($jQuery(this).attr('src') != null) {
                scriptNode.setAttribute('src', ($jQuery(this).attr('src')));
        }
});

You can re-initialize all the scripts once again inside the AJAX success.

// Fetch the scripts
var $scripts;
if ( $scripts.length ) $scripts.detach();
$scripts = $dataBody.find('#document-script');

// Add the scripts
$scripts.each(function(){
        var $script = $(this), 
                scriptText = $script.html(), 
                scriptNode = document.createElement('script');
        try {
                // doesn't work on ie...
                scriptNode.appendChild(document.createTextNode(scriptText));
                contentNode.appendChild(scriptNode);
        } catch(e) {
                // IE has funky script nodes
                scriptNode.text = scriptText;
                contentNode.appendChild(scriptNode);
        }
        if($(this).attr('src') != null) {
                scriptNode.setAttribute('src', ($(this).attr('src')));
        }
});

You can re-initialize all the scripts once again inside the AJAX success.

// Fetch the scripts
scripts = '';
if ( scripts.length ) scripts.detach();
scripts = response.find('script');

// Add the scripts
scripts.each(function(){
        var script = jQuery(this), 
            scriptText = script.html(), 
            scriptNode = document.createElement('script');
        try {
                // doesn't work on ie...
                scriptNode.appendChild(document.createTextNode(scriptText));
                contentNode.appendChild(scriptNode);
        } catch(e) {
                // IE has funky script nodes
                scriptNode.text = scriptText;
                contentNode.appendChild(scriptNode);
        }
        if(jQuery(this).attr('src') != null) {
                scriptNode.setAttribute('src', (jQuery(this).attr('src')));
        }
});
Source Link
Subharanjan
  • 1.6k
  • 1
  • 17
  • 29

You can re-initialize all the scripts once again inside the AJAX success.

// Fetch the scripts
var $scripts;
if ( $scripts.length ) $scripts.detach();
$scripts = $dataBody.find('#document-script');

// Add the scripts
$scripts.each(function(){
        var $script = $(this), 
                scriptText = $script.html(), 
                scriptNode = document.createElement('script');
        try {
                // doesn't work on ie...
                scriptNode.appendChild(document.createTextNode(scriptText));
                contentNode.appendChild(scriptNode);
        } catch(e) {
                // IE has funky script nodes
                scriptNode.text = scriptText;
                contentNode.appendChild(scriptNode);
        }
        if($(this).attr('src') != null) {
                scriptNode.setAttribute('src', ($(this).attr('src')));
        }
});