Mk 27 wrote: > Sorry, yeah, that should be == > > some_func() is in an external file, but it does need to be called from > in the view.
Why? What does it do? Can you use event handlers instead? > Your assertion that "javascript does not belong there" is > patently ridiculous No it's not. It is in fact generally accepted, though there may be a little disagreement over precise details. (I'll admit that I tend to be towards the extreme side of the debate.) > since many of the normal rails functions deploy > JS/AJAX, in the view. Yes, this is one reason I'm not all that keen on the implementation of Rails' JS helpers (although lowpro greatly helps, and it's certainly far easier than doing Ajax without helpers). > A central conceit of rails is XMLHttpRequest, and > it is deployed IN THE VIEW. I wonder if we're using "in the view" in the same sense here. Certainly it's true that the XmlHttpRequest is triggered in the view, but the JavaScript code for it should be in a separate file from the HTML/ERb/Haml/whatever. (Yes, I've used these principles in complex Ajax apps.) Generally speaking, it should never be necessary to have any more JS in your HTML files than you can fit into a simple onclick attribute (actually, even that's not strictly necessary, and I prefer to avoid it when I can through good use of onload). In particular, <script> tags in the body are almost certainly a sign of poor design practice (the exception would be for external libraries like Google Analytics and Facebook Connect). In sum, then...please don't tell me what I say is "patently ridiculous" unless you're sure of it. Rails does not always do things in the best way possible where generating JS (and SQL) is concerned. > > I will investigate writing a helper, thanks. OK. Best, -- Marnen Laibow-Koser http://www.marnen.org [email protected] -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

