Before, in Rails 2.3, I would have expected a remote-form to have an
:update attribute, where you could specify a selector where the response of the remote method would be rendered.
Now it needs to be done differently: my controller function will render a “.js” view, which will do the necessary actions itself. This makes it more library agnostic, and i prefer jquery.
So for instance i have a controller action “search”, and i have a corresponding “search.js.erb” as follows:
This works. It will replace the html of the element with a class
grid with the html from my rendered partial.
I started out trying to achieve that in HAML, and failed at first. So first i created the above ERB code which worked. Now my task seemed simpler: translate this seemingly simple line to HAML.
My first naive approach was to do the following:
But this just places the html as a readable string inside my page. Even i do something simple like
i see the actual characters
After looking through the HAML reference, actually the solution was incredible simple. Once more.
!= unescapes HTML (as opposed to the standard
=). This is exactly what we need of course.