javascript - call .js.erb file instead of .html.erb -
I have a Rail app with Google Maps. I populate it with markers using a .js.erb file I want to do so that I use Ruby Variables in Javascript. I do not want to use gan mani.
Is the action call the .js.erb file instead of the .html.erb file?
On one side, it needs to load .html.erb and then call an automatic ajax to load .jserb, but I am looking for a better solution.
Thank you.
The controller is not really in the correct way, because its job requests have to answer. If a request arrives and the HTML expects to get back, then the train will return the HTML if it is a JS request, then it returns JS.
The correct way to do this is to load the HTML with the page and then make an AJAX call from the page. You can also send it for the same action and the rail will respond with the appropriate jser.b.b template. If you want to give special instructions to it, it may be that if you want to provide your JSON in a specific way, you can do this with a EDIT: It is written under the assumption that you are loading pages via normal HTML request and you want to do it both HTML and JS. If you are already on a page and you want to call HTML without any AJAX calls through a link, button, or form, then by adding any response_to or JBuilder gem.
to
remote: true may do. Form_for for ,
form_tag ,
button_to , or
link_to tag.
Comments
Post a Comment