I have this respond_to block which if a param is present, "format.js" will fire or else "format.html" will fire. My problem is this, the params will never be present initially, only until a user clicks on a link, which then fires an ajax response.
Here is the block:
respond_to do |format|
if params[:tab_id].present?
format.js
else
format.html
end
end
I found this post: JQuery posting form via AJAX not triggering rails respond_to format.js which seems to be a fix, but a reason I don't seem to understand why it works. With my problem, "format.html" will always be first when the page loads. How can I fix this so that "format.js" will fire when the user clicks on a link so that a params will be present?