Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

button_to my_routed_path(a: "ok", b: "or", c: "not?"), remote: true does NOT call JS rendering #513

Open
jerome-diver opened this issue Jan 8, 2019 · 1 comment

Comments

@jerome-diver
Copy link

jerome-diver commented Jan 8, 2019

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)

@jerome-diver
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant