Actually,
The following code seems to be working in ie and firefox for me, but it was
a very simple test.
Alex
processScript: function(steps, node) {
steps.push(function(notify) {
if (Wicket.DOM.containsElement(node) ||
Wicket.Head.containsElement(node, "src")) {
notify();
return;
}
var src = node.getAttribute("src");
if (src != null && src != "") {
var script = Wicket.Head.createElement("script");
script.src = src;
var done = false;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function(){
if ( !done && (!this.readyState ||
this.readyState == "loaded" ||
this.readyState== "complete") ) {
done = true;
var head = document.getElementsByTagName("head");
if (head[0]) {
// how about Wicket.Head.removeElement() ???
head[0].removeChild(script);
}
// maybe I need to do something here?
notify();
}
};
Wicket.Head.addElement(script);
//var onLoad = function() {
// Wicket.Head.addJavascript(content, null, src);
// Wicket.Ajax.invokePostCallHandlers();
// notify();
//}
// we need to schedule the request as timeout
// calling xml http request from another request call stack
doesn't work
//window.setTimeout(function() {
// var req = new Wicket.Ajax.Request(src, onLoad, false,
false);
// req.debugContent = false;
// if (Wicket.Browser.isKHTML())
// req.async = false;
// req.get();
// },1);
} else {
var text = Wicket.DOM.serializeNodeChildren(node);
Wicket.Head.addJavascript(text, node.getAttribute("id"));
notify();
}
});
}
On 10/18/07, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
>
> matej what do you think about this?
>
> -igor
>
>
> On 10/18/07, Alexei Sokolov <[EMAIL PROTECTED]> wrote:
> > Maybe something similar to this:
> > http://docs.jquery.com/Ajax/jQuery.getScript. They use <script> tag
> > injection (see 1.2.1 jquery source code).
> >
> > Alex
> >
> > On 10/18/07, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> > >
> > > do you have any suggestions on how to fix it?
> > >
> > > -igor
> > >
> > >
> > > On 10/18/07, Alexei Sokolov <[EMAIL PROTECTED]> wrote:
> > > > Hey guys,
> > > >
> > > > Very good progress on 1.3 release, congratulations.
> > > > However, there is an issue which somebody complained around july
> 31,
> > > > 07 that has not been
> > > > addressed yet.
> > > >
> > > > Short description: I cannot reference any external javascript files
> > > (from
> > > > yahoo, google, even from subdomain) in markup of a panel if I want
> that
> > > > panel to be updated using ajax. All browsers complain.
> > > >
> > > > Long Description: I believe the problem lies inside wicket-ajax.js,
> more
> > > > precisely in Wicket.Head.Contributor.ProcessScript method. Existing
> > > > implementation attempts to load the referenced script using ajax,
> and
> > > > browsers do not allow that due to security concerns. See any article
> on
> > > > cross-domain ajax for the explanation why.
> > > >
> > > > Steps to reproduce:
> > > >
> > > > 1. create a panel.
> > > > 2. include something like <wicket:head><script
> type="text/javascript"
> > > src="
> > > > http://blah.blah.com/script.js"></script></wicket:head>
> > > > 3. attempt to update the panel using ajax
> > > > 4. each and every browser will complain, but the error will be
> > > > slightly different. firefox will say "uncaught exception: Permission
> > > > denied to call method XMLHttpRequest.open"
> > > >
> > > >
> > > > Alex
> > > >
> > >
> >
>