Hello everyone,
Here is my problem. I have a page that gets fetched by an ajax
request. I have
onComplete: function(transport) {
$(''element'').update(transport.responseText);
}
The update in turn calls evalScripts and runs all of the javascript
inside of script (<script></script>) tags, but I also have linked
javascript files (<script src="whatever.js"></script>) in
the
requested page that evalScripts doesn''t handle.
I''m just wondering why prototype doesn''t handle these included
scripts? Is it a conscious design decision?
Thanks,
James Starmer
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Please post the code for your ajax call. On Jul 12, 5:10 pm, James Starmer <jamesstar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello everyone, > Here is my problem. I have a page that gets fetched by an ajax > request. I have > > onComplete: function(transport) { > $(''element'').update(transport.responseText); > > } > > The update in turn calls evalScripts and runs all of the javascript > inside of script (<script></script>) tags, but I also have linked > javascript files (<script src="whatever.js"></script>) in the > requested page that evalScripts doesn''t handle. > > I''m just wondering why prototype doesn''t handle these included > scripts? Is it a conscious design decision? > > Thanks, > James Starmer--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
James Starmer
2007-Jul-13 15:28 UTC
Re: Why doesn''t evalScripts evaluate external js files
new Ajax.Request(url,{
method: ''post'',
onComplete: function(transport) {
tab.linkedPanel.update(transport.responseText);
}
});
tab.linkedPanel is an empty <div>.
On Jul 13, 10:41 am, Diodeus
<diod...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Please post the code for your ajax call.
>
> On Jul 12, 5:10 pm, James Starmer
<jamesstar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > Hello everyone,
> > Here is my problem. I have a page that gets fetched by an ajax
> > request. I have
>
> > onComplete: function(transport) {
> > $(''element'').update(transport.responseText);
>
> > }
>
> > The update in turn calls evalScripts and runs all of the javascript
> > inside of script (<script></script>) tags, but I also have
linked
> > javascript files (<script
src="whatever.js"></script>) in the
> > requested page that evalScripts doesn''t handle.
>
> > I''m just wondering why prototype doesn''t handle
these included
> > scripts? Is it a conscious design decision?
>
> > Thanks,
> > James Starmer
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Looks like you may actually want Ajax.Updater, which has an
evalScripts option.
http://prototypejs.org/api/ajax/updater
new Ajax.updater(tab.linkedPanel, url, {
//method: ''post'', //Is already default method
//parameters: Form.serialize(''formId''), //Do you need to
pass any
parameters?
evalScripts: true
});
Does that work for you?
TAG
On Jul 13, 2007, at 9:28 AM, James Starmer wrote:
>
> new Ajax.Request(url,{
> method: ''post'',
> onComplete: function(transport) {
> tab.linkedPanel.update(transport.responseText);
> }
> });
>
> tab.linkedPanel is an empty <div>.
>
> On Jul 13, 10:41 am, Diodeus
<diod...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> Please post the code for your ajax call.
>>
>> On Jul 12, 5:10 pm, James Starmer
<jamesstar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>>
>>> Hello everyone,
>>> Here is my problem. I have a page that gets fetched by an ajax
>>> request. I have
>>
>>> onComplete: function(transport) {
>>> $(''element'').update(transport.responseText);
>>
>>> }
>>
>>> The update in turn calls evalScripts and runs all of the javascript
>>> inside of script (<script></script>) tags, but I also
have linked
>>> javascript files (<script
src="whatever.js"></script>) in the
>>> requested page that evalScripts doesn''t handle.
>>
>>> I''m just wondering why prototype doesn''t handle
these included
>>> scripts? Is it a conscious design decision?
>>
>>> Thanks,
>>> James Starmer
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
James Starmer
2007-Jul-13 17:03 UTC
Re: Why doesn''t evalScripts evaluate external js files
Tom, That didn''t really help, thanks though. The .update (aka Element.update) calls evalScripts.>From the api http://www.prototypejs.org/api/element/update :"If it contains any <script> tags, these will be evaluated after element has been updated (Element.update internally calls String#evalScripts)." So using Ajax.Updater vs. Ajax.Request isn''t the issue. I don''t have trouble with evalScripts handling scripts that are in the page being fetched by ajax. My problem is when that page includes a separate javascript file like <script src="whatever.js"></script>. evalScripts doesn''t handle those. It''s more of a prototype design question than a help me with this bug question because I don''t think it''s a bug. Thanks, James Starmer On Jul 13, 11:41 am, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote:> Looks like you may actually want Ajax.Updater, which has an > evalScripts option.http://prototypejs.org/api/ajax/updater > > new Ajax.updater(tab.linkedPanel, url, { > //method: ''post'', //Is already default method > //parameters: Form.serialize(''formId''), //Do you need to pass any > parameters? > evalScripts: true > > }); > > Does that work for you? > > TAG > > On Jul 13, 2007, at 9:28 AM, James Starmer wrote: > > > > > new Ajax.Request(url,{ > > method: ''post'', > > onComplete: function(transport) { > > tab.linkedPanel.update(transport.responseText); > > } > > }); > > > tab.linkedPanel is an empty <div>. > > > On Jul 13, 10:41 am, Diodeus <diod...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Please post the code for your ajax call. > > >> On Jul 12, 5:10 pm, James Starmer <jamesstar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>> Hello everyone, > >>> Here is my problem. I have a page that gets fetched by an ajax > >>> request. I have > > >>> onComplete: function(transport) { > >>> $(''element'').update(transport.responseText); > > >>> } > > >>> The update in turn calls evalScripts and runs all of the javascript > >>> inside of script (<script></script>) tags, but I also have linked > >>> javascript files (<script src="whatever.js"></script>) in the > >>> requested page that evalScripts doesn''t handle. > > >>> I''m just wondering why prototype doesn''t handle these included > >>> scripts? Is it a conscious design decision? > > >>> Thanks, > >>> James Starmer--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I see.
Have you tried passing Javascript that would load an external file? I
mean, rather than passing <script src="..."></script>,
passing
something like the following:
<script type="text/javascript">
function loadJs (fileName) {
var head = document.getElementsByTagName("head")[0];
var s = document.createElement(''script'');
s.type = ''text/javascript'';
s.src = fileName;
head.appendChild(s);
}
loadJs(''/js/someFile.js'');
</script>
TAG
On Jul 13, 2007, at 11:03 AM, James Starmer wrote:
>
> Tom,
> That didn''t really help, thanks though. The .update (aka
> Element.update) calls evalScripts.
>
>> From the api http://www.prototypejs.org/api/element/update :
> "If it contains any <script> tags, these will be evaluated after
> element has been updated (Element.update internally calls
> String#evalScripts)."
>
> So using Ajax.Updater vs. Ajax.Request isn''t the issue.
>
> I don''t have trouble with evalScripts handling scripts that are in
the
> page being fetched by ajax. My problem is when that page includes a
> separate javascript file like <script
src="whatever.js"></script>.
> evalScripts doesn''t handle those.
>
> It''s more of a prototype design question than a help me with this
bug
> question because I don''t think it''s a bug.
>
> Thanks,
> James Starmer
>
> On Jul 13, 11:41 am, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org>
wrote:
>> Looks like you may actually want Ajax.Updater, which has an
>> evalScripts option.http://prototypejs.org/api/ajax/updater
>>
>> new Ajax.updater(tab.linkedPanel, url, {
>> //method: ''post'', //Is already default method
>> //parameters: Form.serialize(''formId''), //Do you
need to pass any
>> parameters?
>> evalScripts: true
>>
>> });
>>
>> Does that work for you?
>>
>> TAG
>>
>> On Jul 13, 2007, at 9:28 AM, James Starmer wrote:
>>
>>
>>
>>> new Ajax.Request(url,{
>>> method: ''post'',
>>> onComplete: function(transport) {
>>> tab.linkedPanel.update
>>> (transport.responseText);
>>> }
>>> });
>>
>>> tab.linkedPanel is an empty <div>.
>>
>>> On Jul 13, 10:41 am, Diodeus
<diod...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>>>> Please post the code for your ajax call.
>>
>>>> On Jul 12, 5:10 pm, James Starmer
<jamesstar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>>
>>>>> Hello everyone,
>>>>> Here is my problem. I have a page that gets fetched by an
ajax
>>>>> request. I have
>>
>>>>> onComplete: function(transport) {
>>>>>
$(''element'').update(transport.responseText);
>>
>>>>> }
>>
>>>>> The update in turn calls evalScripts and runs all of the
>>>>> javascript
>>>>> inside of script (<script></script>) tags, but
I also have linked
>>>>> javascript files (<script
src="whatever.js"></script>) in the
>>>>> requested page that evalScripts doesn''t handle.
>>
>>>>> I''m just wondering why prototype doesn''t
handle these included
>>>>> scripts? Is it a conscious design decision?
>>
>>>>> Thanks,
>>>>> James Starmer
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
James Starmer
2007-Jul-13 20:52 UTC
Re: Why doesn''t evalScripts evaluate external js files
Thanks Tom, I actually came up with a solution that uses that append code, but it parses the source file names out of the code and loads them dynamically when the ajax page is loaded. I posted the script on my blog if anyone is interested. http://www.jamesstarmer.com/2007/07/13/dynamic-script-loader/ Thanks, James On Jul 13, 4:03 pm, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote:> I see. > > Have you tried passing Javascript that would load an external file? I > mean, rather than passing <script src="..."></script>, passing > something like the following: > > <script type="text/javascript"> > function loadJs (fileName) { > var head = document.getElementsByTagName("head")[0]; > var s = document.createElement(''script''); > s.type = ''text/javascript''; > s.src = fileName; > head.appendChild(s);} > > loadJs(''/js/someFile.js''); > </script> > > TAG > > On Jul 13, 2007, at 11:03 AM, James Starmer wrote: > > > > > Tom, > > That didn''t really help, thanks though. The .update (aka > > Element.update) calls evalScripts. > > >> From the apihttp://www.prototypejs.org/api/element/update: > > "If it contains any <script> tags, these will be evaluated after > > element has been updated (Element.update internally calls > > String#evalScripts)." > > > So using Ajax.Updater vs. Ajax.Request isn''t the issue. > > > I don''t have trouble with evalScripts handling scripts that are in the > > page being fetched by ajax. My problem is when that page includes a > > separate javascript file like <script src="whatever.js"></script>. > > evalScripts doesn''t handle those. > > > It''s more of a prototype design question than a help me with this bug > > question because I don''t think it''s a bug. > > > Thanks, > > James Starmer > > > On Jul 13, 11:41 am, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote: > >> Looks like you may actually want Ajax.Updater, which has an > >> evalScripts option.http://prototypejs.org/api/ajax/updater > > >> new Ajax.updater(tab.linkedPanel, url, { > >> //method: ''post'', //Is already default method > >> //parameters: Form.serialize(''formId''), //Do you need to pass any > >> parameters? > >> evalScripts: true > > >> }); > > >> Does that work for you? > > >> TAG > > >> On Jul 13, 2007, at 9:28 AM, James Starmer wrote: > > >>> new Ajax.Request(url,{ > >>> method: ''post'', > >>> onComplete: function(transport) { > >>> tab.linkedPanel.update > >>> (transport.responseText); > >>> } > >>> }); > > >>> tab.linkedPanel is an empty <div>. > > >>> On Jul 13, 10:41 am, Diodeus <diod...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >>>> Please post the code for your ajax call. > > >>>> On Jul 12, 5:10 pm, James Starmer <jamesstar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>>>> Hello everyone, > >>>>> Here is my problem. I have a page that gets fetched by an ajax > >>>>> request. I have > > >>>>> onComplete: function(transport) { > >>>>> $(''element'').update(transport.responseText); > > >>>>> } > > >>>>> The update in turn calls evalScripts and runs all of the > >>>>> javascript > >>>>> inside of script (<script></script>) tags, but I also have linked > >>>>> javascript files (<script src="whatever.js"></script>) in the > >>>>> requested page that evalScripts doesn''t handle. > > >>>>> I''m just wondering why prototype doesn''t handle these included > >>>>> scripts? Is it a conscious design decision? > > >>>>> Thanks, > >>>>> James Starmer--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---