View Full Version : scripts - autoLoad vs. Ajax

23 Jul 2009, 6:15 PM
High level question, is there a way to get functionality like the scripts: true option for autoLoad to work for a generic Ajax request?

More detailed situation:

I have a panel that initially contains some basic HTML. After an event occurs (item selected from combobox) I need to make an Ajax call to the server which returns me some HTML (with a single line of javascript that needs to be executed). The HTML should replace the HTML should replace the HTML in the panel and also execute the javascript.

My first approach was to have the event handler for the combo box select make an Ajax request, get the response and stuff it into the panel. This works except that the javascript doesn't execute.

Just to test I changed the panel to use autoLoad and hardcoded the server call & parameters, this worked in that it called server, got the HTML and executed the JS.

My problem is I sort of need to be able to combine the two approaches - that is call the server and pass it information from the selected combo box AND have it execute the JS. Any tips on which of the approaches is closer and how to proceed are appreciated.


24 Jul 2009, 12:30 AM
autoLoad also does an XHR request, renders the result and evaluates any script tags it finds inside.

Could you use something like:

xtype: 'combo',
store: ['A', 'B', 'C'],
triggerAction: 'all',
editable: false,
listeners: {
select: function(combo, record, index){
url: 'content.php',
params: {
'page': record.get(combo.displayField)
scripts: true
xtype: 'panel',
id: 'content'

24 Jul 2009, 4:45 AM
Perfect that does exactly what I was looking for.