PDA

View Full Version : UpdateManager loadScripts not working



raphinou
2 May 2007, 9:32 AM
Hi,

I'm updating an element with html and javascript, but I can't make the script being run. What am I missing in my code?


var user_event = Ext.get('user_event');
user_event_mgr = user_event.getUpdateManager();
user_event_mgr.showLoadIndicator = false;
user_event_mgr.loadScripts = true;
user_event_mgr.update( { url: ' /get_fragment.html' });


and get_fragment.html contains


<script type="text/javascript">
Ext.MessageBox.alert("test", "test");
</script>


I've also called this


user_event_mgr.update( { url: ' /get_fragment.html' });

which from looking at the code should be equivalent.

I'm afraid I missed something obvious and would be grateful if someone could point me where....

thanks

Raph

raphinou
2 May 2007, 11:33 AM
Does anyone have a working example of UpdateManager and loadScripts so I could compare the code?

thanks

raph

tryanDLS
2 May 2007, 2:06 PM
There are a number of threads related to this. However, I would suggest that you check in firebug that the request is being made and is coming back correctly.

raphinou
2 May 2007, 11:15 PM
Hi,

thanks for your suggestion. I'm indeed working with firebug, and the request is going out and content is put in the destination div. It's just that the javascript code isn't run. I've looked at the forum but didn't find a solution to my problem.

When I access the fragment directly with the browser the javascript is run. It's really something with the UpdateManager.

Raph

72
3 May 2007, 12:11 AM
..javascript code isn't run..

Just try get pure javascript alert() instead of Ext.. and make sure that this code will not be executed..

raphinou
3 May 2007, 8:09 AM
The alert is not shown.
When using the call with {scripts: true, url: ....} (event if I set mgr.loadScripts=true ) and inspecting with firebug, the script tag isn't even in the tree.

when setting mgr.loadScripts=true only, the tag is there:


<script type="text/javascript">
alert('test');
</script>


but it's not executed.

I've tried with Ext 1.0.1a, with the same result. I've tried with other browsers and with firebug disabled, still with the same result....

The server returns a text/html document. When I access it directly with the browser the alert is shown.

Raph

tryanDLS
3 May 2007, 8:48 AM
I just tested this and can't duplicate the problem. Are you using the yui-adapter? Try setting a BP in UpdateManager.processSuccess and see what it does. Also try putting a couple characters after your closing script tag in the fragment and see if they get output to your div.

raphinou
3 May 2007, 9:28 AM
I just tested this and can't duplicate the problem. Are you using the yui-adapter? Try setting a BP in UpdateManager.processSuccess and see what it does. Also try putting a couple characters after your closing script tag in the fragment and see if they get output to your div.

I'm using the prototype adapter. I'll see if I can test with yui.
I put characters before and after the script part, and they were in the output.
I had put a firebug console.log call in the UpdateManager code but didn't get anything in the console. I thought it was a firebug problem but will look further to that.

thanks for your suggestions, I'll come back with more info.

raph

Animal
3 May 2007, 10:42 AM
Someone else hit this with prototype. Don't use it.

raphinou
3 May 2007, 12:23 PM
Someone else hit this with prototype. Don't use it.

Thanks for this clarification.

But is it planned to correct this problem? I tried 1.0.1a and the problem was still there. Wouldn't it be good to report this issue?

Raph

tryanDLS
3 May 2007, 12:36 PM
It's a reported bug here (http://extjs.com/forum/showthread.php?t=5182), but it's a problem in the prototype code itself, not the adapter.

raphinou
3 May 2007, 11:54 PM
It's a reported bug here (http://extjs.com/forum/showthread.php?t=5182), but it's a problem in the prototype code itself, not the adapter.

The code seems to be eval'd though, so I thought it would run fine. Anyway, I think I'll switch back to yui.

JorisA
5 May 2007, 4:47 AM
I've got the same problem, works fine with YUI, but doenst do anything on protoype.
I need scriptalicous for my image cropper. is there a way to make this working?