Reputation: 797
I have next code in controller:
def show
respond_to { |format|
format.html
format.js
}
end
And I have two views - show.html.haml
and show.js.haml
.
I have opened a page in browser and received HTML.
But if I have used jquery-ujs
and link with remote: true
, I have received JS.
In documentation written:
Rails determines the desired response format from the HTTP Accept header submitted by the client.
But If using jquery-ujs, Accept always text/javascript, application/javascript, application/ecmascript, application/x-ecmascript
How I can receive HTML in this case?
Upvotes: 0
Views: 144
Reputation: 4015
You can just add the format: :html
to your link-to
helper, like this:
= link_to "Product", [:admin, @product], format: :html, remote: true
But then you need some javascript function, which will handle the callback of this ajax call, and do something with the fetched html
Upvotes: 1