button_to my_routed_path(a: "ok", b: "or", c: "not?"), remote: true does NOT call JS rendering
jerome-diver opened this issue · 1 comments
my partial _view:
= button_to "Do something good this day", my_rooted_path(a: "OK", b: "or", c: "NOT ?"), remote: true, class: "what ever"
my "my_routed_path" route:
my_routed /my/id:/a:(.:format) my#own_action
my_controller.rb (action part):
def own_action
... do something easy...
repond_to do |f[
f.html { render blablabla...}
f.js { render layout: false } (or just f.js the same...)
end
i have a file named "my_own.js.coffee":
console.log("Very good !")
And at click time on button "Do something good this day"
i expect my rails-5.2.2 application to show me in the console log: "Very good !"...
but not. New page load the html render and yes, my rails puma server logs show me that it is html render who has been called.
Why ?
How to call JS from this button ? all the other "conventional" routed path are fine, so maybe it is a kind of ugly bug ? (not sure as long as i not understand why it doesn't call JS render and then render the action_named dot js dot coffee file)
ok, i just understand my error:
button_to does NOT create a %button, but a form... so when this button is allready inside a form it becomes a kind of nested things (it should not).
For have a (independent) button, i need to use link_to ... type: "button", method: :post, remote: true