Rails 3 UJS - on hover, not on click

For my show action, I show show.js.erb. This happens when I click the link_to link with the setting :remote => true. How can I set it up so that it works on hover?

+3
source share
2 answers

Create a link with an attribute that will not run the Rails-UJS driver:

<%= link_to 'mouse over me!', '#', :'data-remote-on-hover' => true %>

and then hook your own event:

$('a[data-remote-on-hover]').hover(function() {
  // do something
})
+2
source

Source: https://habr.com/ru/post/1777136/


All Articles