I would like to execute javascript on the pages that I load through Ext.Ajax.request. To do this, I have to download the scripts and eval()them as follows:
Ext.Ajax.request({
url: 'content/view_application.php',
success: function(objServerResponse) {
var responseText = objServerResponse.responseText;
regionContent.update(responseText);
var scripts, scriptsFinder=/<script[^>]*>([\s\S]+)<\/script>/gi;
while(scripts=scriptsFinder.exec(responseText)) {
eval(scripts[1]);
}
}
});
However, with jQuery, I can run Javascript on pages that are invoked through AJAX without resorting to the eval()following:
function replaceContentOnClick(id, pageToLoad) {
$('body').delegate(('#' + id), 'click', function(){
$.get('content/' + pageToLoad, function(data) {
$('#regionContent .x-panel-body').html(data);
});
});
}
How does jQuery manage to execute javascript on a loaded page without eval()? Is there a way to load javascript without resorting to eval()in ExtJS?
source
share