[Rails-spinoffs] innerHTML and scripts not running
Irfan, Ghouseuddin Syed
isyed at corp.untd.com
Thu Apr 13 05:37:23 GMT 2006
Hi,
You can always do a response.responseText.evalScripts() in the onComplete function.
Eg:
onComplete: function(response) {
// xyz
//xyz
response.responseText.evalScripts()
}
Hope this helps.
Thanks,
Irfan
-----Original Message-----
From: rails-spinoffs-bounces at lists.rubyonrails.org
[mailto:rails-spinoffs-bounces at lists.rubyonrails.org]On Behalf Of Al
Sent: Thursday, April 13, 2006 1:53 AM
To: rails-spinoffs at lists.rubyonrails.org
Subject: Re: [Rails-spinoffs] innerHTML and scripts not running
Thanks for the reply. Apparently evalScripts doesn't work for Ajax.Request().
According to the documentation in
http://wiki.script.aculo.us/scriptaculous/revision/Ajax.Request:
Note: even though the Rails helpers inject it as an option, the
'evalScripts' option does not work with Ajax.Request. See Ajax.Updater
if you want 'evalScripts' to work.
I'm using Ajax.Updater() now, and it works great. Thanks for the lead!
On 4/12/06, Gregory Hill <Gregory_Hill at tni.com> wrote:
> Add 'evalScripts: true' to your options on the Ajax.Request constructor.
>
> Setting innerHTML with javascript does not cause the javascript to be
> invoked.
>
> Greg
>
> > -----Original Message-----
> > From: rails-spinoffs-bounces at lists.rubyonrails.org
> [mailto:rails-spinoffs-
> > bounces at lists.rubyonrails.org] On Behalf Of Al
> > Sent: Wednesday, April 12, 2006 1:05 PM
> > To: rails-spinoffs at lists.rubyonrails.org
> > Subject: [Rails-spinoffs] innerHTML and scripts not running
> >
> > Hello,
> >
> > I'm having an issue with getting embedded javascript code to actually
> > run when loaded via an Ajax.Request() call and the callback function
> > inserts the generated HTML and js code to my current page. It seems
> > that the javascript code is not properly parsing.
> >
> > For example, I'm using the following function showinfo() to return
> > some html code.
> >
> > function showInfo(go_url){
> > if($("display_area") && go_url){
> >
> > var xmlHttp= new Ajax.Request(go_url, {method: "post",
> > parameters: Form.serialize(document.forms[0]),
> > onComplete:function(){
> >
> > if(xmlHttp.responseIsFailure()) {
> > var sts = xmlHttp.transport.status ? xmlHttp.
> > transport.status : "undefined";
> > $("debug_msg").value=
> > "XMlHttpRequest returned response status "+sts;
> > document.getElementById("debug_msg").innerHTML=
> > "HTTP response and server information; "+
> > "response status="+
> > xmlHttp.transport.status;
> > } else {
> > document.getElementById("display_area").innerHTML
> > =xmlHttp.transport.responseText;
> >
> > document.getElementById("debug_msg").innerHTML=
> > "HTTP response and server information; "+
> > "response status="+ xmlHttp.transport.status;
> > }
> > }});
> > }
> > }
> >
> >
> > Now, in the line
> >
> >
> document.getElementById("display_area").innerHTML=xmlHttp.transport.resp
> on
> > seText;
> >
> > Generated by the link saved in go_url, I have html code that I derived
> > from the examples in ajax_inplaceeditor_test.html to appear in between
> > my <div id="display_area"> tags. The inplace editing functionality
> > works when I run the go_url link on its own, but when I embed it in
> > the manner above, the html properly appears, but the code does not
> > run.
> >
> > Am I doing the right thing to use innerHTML?
> >
> >
> > -Al
> > _______________________________________________
> > Rails-spinoffs mailing list
> > Rails-spinoffs at lists.rubyonrails.org
> > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> _______________________________________________
> Rails-spinoffs mailing list
> Rails-spinoffs at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
>
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs at lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
More information about the Rails-spinoffs
mailing list