Im not JS expert, and I dont know Ruby, but i think:
When datatype is set to script
- downloaded code is loaded and executed immediately.
When datatype is default (html
) - downloaded code is just loaded into browser. You have to execute it "manually" (by calling some function for example).
If your code has just some functions for use with previously loaded code - these functions will be available and will work (when data type is html
).
If there are defined events in your code - they will not work because they are not initialized, becuase code was not executed.
If my explanation is bad - you may read about difference between jQuery.get()
and jQuery.getScript()
methods.