Hi David, > Could you please point me out where it is written, I've perhaps miss > something.
It's cleverly hidden on the docs for Ajax.Updater: http://prototypejs.org/api/ajax/updater A better place would (obviously) be on String#evalScripts, which someone helpfullly pointed out by opening a ticket in Lighthouse a while back (https://prototype.lighthouseapp.com/projects/8886- prototype/tickets/38). HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On May 25, 6:25 pm, david <david.brill...@gmail.com> wrote: > Hi Mickael, > > I just look at the prototype documentation, and did not find any note > about: > > > According to the Prototype documentation, you need to declare the > > function and assign it to a global variable: > > > myFunction = function() {alert('hi');} > > Could you please point me out where it is written, I've perhaps miss > something. > > Because for me, there is no much difference in JS between: > var myFunction=function(){alert('myFunction');} > and > function myFunction(){alert('myFunction');} > that should return a function named myFunction that in both case could > be called as myFunction(). > > I think you could define your function the way you want even in an > AJAX call, because it's just handle (in certain case) the call to the > eval() method which will only evaluate the JS code. > > For you're exemple, I think that > var myFunction = function myFunction() {alert('hi');} just create a > function called myFunction and assign this function to a variable > called myFunction, that result in a function called myFunction() ==> I > think it is redondant. > > -- > david > > On 24 mai, 16:24, Michael <mich...@michaelminella.com> wrote: > > > I understand how Prototype works with regards to the removal of > > <script> tags after evaling the results of an Ajax request. However, > > I was doing some research and am now starting to wonder why the way I > > declare functions works. > > > According to the Prototype documentation, you need to declare the > > function and assign it to a global variable: > > > myFunction = function() {alert('hi');} > > > That makes sense. However, in all of my scenarios, I've declared > > functions like this: > > > var myFunction = function myFunction() {alert('hi');} > > > and the calls to myFunction work just fine. My question is...why does > > my way work? According to the Prototype documentation, the local > > variable myFunction should be thrown away after the eval. Any insight > > anyone can provide would be appreciated. Thanks in advance! > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---