On 22.8.2006, at 16.18, Eduardo Yáñez Parareda wrote:
> > Thank for the answer. > >> Neither of them do that. They are just helpers that produce html (see >> above). One creates a normal link, the other an Ajax link. > > Yes, I know it, I was talking about the flow produced when you click a > link generated by > link_to that points to a controller's action. It doesn't depend on that. You can write your links by hand or produce them with PHP or whatever. They're just links. In the responding action on the server side you can detect whether it was called by XmlHttpRequest (request.xhr?), or any of the standard http methods (request.post?, get?, etc) and do whatever you want to depending on that. However, by default actions render a template with the same name as the action, be it an rhtml, rxml or rjs template (in that order IIRC). They don't automatically detect how the action was called. In your case, there was an rjs template so it was rendered. The problem was that you had called it with a standard http get request. The browser thought that it was getting a full new html page back, and thus rendered the javascript code as text. If you had called it with a JavaScript Ajax.Request (using link_to_remote), the response would have been correctly executed as JavaScript (in the browser). But like said, this doesn't really matter to the backend. You could use an Ajax.Updater call (using the :update attribute with link_to_remote) instead and the called action would render normal html without even knowing that the response is used inside an Ajax action. Bottom line: 1) From the server perspective, the flow is basically the same. However, 2) You *can't* use link_to with Ajax actions because it doesn't produce an Ajax call. But this is because of the frontend (the browser), not because of differences on the server side. //jarkko -- Jarkko Laine http://jlaine.net http://odesign.fi --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" 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-spinoffs -~----------~----~----~----~------~----~------~--~---
