I am working with the Yahoo Maps API and I’d like to only include the
Yahoo javascript library on demand. I have a link_to_remote that shows a
Yahoo Map. Rather than the Yahoo library on every page it
seems more efficient to load this as part of my RJS partial (“on
demand”).
Is this possible? It doesn’t seem like it. Can be honored
by a browser when returned from an AJAX call?
When I load the Yahoo js library as part of the regular HTTP page it
works fine.
This does not seem to work. For one thing I can’t find any reference to
“type” or “src” methods for DOM elements.
This works just fine. If you have firefox developer toolbar installed,
go to the view source tab, then “view generated source” and it will show
you that the
You are creating a new page element and assigning it to the variable
script. id, type and src are attributes you’re setting on that page
element object.
you could do: script.madeupcrap = “stuff”; and it would write out an
attribute like:
Copy and paste the code into just an html doc and run it in your
browser. If you’re scripts aren’t being eval-ed on return of your
link_to_remote call, that might be the issue.
Set your RJS return to do an alert or something to let you know the
request was sent back: alert(‘i worked, yay!’); or something.
Also, the Firebug plugin for Firefox is great to debug ajax requests
with. Shows you what happened round trip.
This does not seem to work. For one thing I can’t find any reference to
“type” or “src” methods for DOM elements.
This works just fine. If you have firefox developer toolbar installed,
go to the view source tab, then “view generated source” and it will show
you that the tag was appended to the bottom of the tag.
Yeah, it actually sort of works… but not with Safari. I found a couple
threads on a Prototype mailing list discussing it.
At any rate, I may just leave it in the original page. It should be
cached I believe, so I’m now wondering if it’s worth all the trouble…
This does not seem to work. For one thing I can’t find any reference to
“type” or “src” methods for DOM elements.
or the shorter prototype way:
new Insertion.Bottom(‘id_of_place_u_want_it’, script)
This does not work either. Apparently prototype doesn’t support external
scripts. There’s a patch for it but Rails/Prototype don’t seem to be
interested:
It does work fine when I include the javascript on the original page
whether a map is ever loaded or not, but there’s a noticeable hit on the
page loading times.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.