Using Prototype to load a JavaScript file from another domain?

Check this out.. It seems that there is a specific plugin which enables the functionality in Prototype library, the author mentions that e.g. JQuery supports it already for a long time, but it seems it's not supported by default it Prototype.

Thanks Thomas, that was very helpful, I took a look at that which lead me to create and insert a script element to the api URL in the body in my answer. You could also do it in the head but for the facebook api which I'm using they recommend putting it in the body. – Eliot Sykes Jan 23 '10 at 12:58.

Thx to Thomas's answer, I created a FacebookApiLoader class to do this. Here's the source, only tested in Firefox 3 at the moment. Hope this helps someone.

What this does is looks to see if there are any facebook api dependent elements on the page, and if there are then it will load the facebook api script by inserting it before the body closing tag. This relies on the PrototypeJS library. Call facebookApiLoader.observe() in a page that might require the facebook api.

Var FacebookApiLoader = Class. Create({ initialize: function() { this. Observer = null this.

ObservedElement = null }, apiDependentsVisible: function() { if (null == this. ObservedElement) { // $('facebook-login') is a div in my site that // is display:none initially. Once it is made // visible then the facebook api is needed.

// Replace 'facebook-login' with id relevant for your site this. ObservedElement = $('facebook-login') } return this.observedElement.visible() }, apiLoadCompleted: function() { try { return!Object. IsUndefined(FB) &&!Object.

IsUndefined(FB_RequireFeatures) } catch (e) { } return false }, initAndRequireFeatures: function() { FB_RequireFeatures("XFBML", function() { FB. Init('secret-put-your-app-value-here','/xd_receiver. Html', {}) } ); }, initFacebookConnect: function() { new PeriodicalExecuter(function(pe) { if (this.

ApiLoadCompleted()) { this. InitAndRequireFeatures() pe.stop() } }. Bind(this), 0.2); }, loadApi: function() { // Use body for facebook script as recommended in Facebook // docs not to insert in head as some browsers have // trouble with it body = $$('body')0 // TODO use https protocol if page is secure script = new Element('script', { 'type': 'text/javascript', 'src': 'http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php' }) body.

AppendChild(script) this. InitFacebookConnect() }, loadApiIfRequired: function() { if (this. ApiDependentsVisible()) { this.observer.stop() this.loadApi() } }, observe: function() { if (null == this.

Observer) { this. Observer = new PeriodicalExecuter(this. LoadApiIfRequired.

Bind(this), 0.2) } } }); // The FacebookApiLoader attributes are lazily loaded // so creating a new facebookApiLoader // is as low resource usage as possible var facebookApiLoader = new FacebookApiLoader(); Then on any page that might need the Facebook api on demand, call facebookApiLoader.observe().

Thx to Thomas's answer, I created a FacebookApiLoader class to do this. Here's the source, only tested in Firefox 3 at the moment. Hope this helps someone.

What this does is looks to see if there are any facebook api dependent elements on the page, and if there are then it will load the facebook api script by inserting it before the body closing tag. This relies on the PrototypeJS library. Call facebookApiLoader.observe() in a page that might require the facebook api.

Jameson 12 Yr Old Irish Whiskey. Bottle price: $34.99.

Here's one way I found to accomplish what I was trying to do, although it seems like there must be a more direct way Also, I should add that the data is being rendered to xml in my controller so this seems to fit nicely with that def datetime self. Datetime_before_type_cast # => 2010-01-20 12:00:00.123 end #override to_xml, excluding the datetime field and replacing with the method of the same name def to_xml(options = {}) super(:methods => :datetime, :except => :datetime) end SomeModel.first. To_xml ... 2010-01-20 12:00:00.123.

Here's one way I found to accomplish what I was trying to do, although it seems like there must be a more direct way. Also, I should add that the data is being rendered to xml in my controller so this seems to fit nicely with that. Def datetime self.

Datetime_before_type_cast # => 2010-01-20 12:00:00.123 end #override to_xml, excluding the datetime field and replacing with the method of the same name def to_xml(options = {}) super(:methods => :datetime, :except => :datetime) end SomeModel.first. To_xml ... 2010-01-20 12:00:00.123 ...

If there is no default value, the result will be nil, EVEN if type casting is provided. Thus, a field typically cast as an Integer can be nil. See calculation of average example.

Note: When a default value and a klass are specified, the default value will NOT be cast to type klass -- you must do it. Setting an attribute to nil always results in it being nil. Default values, pre-defined formatters, and custom formatters have no effect.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions