You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This gem is fantastic!
The only issue I have is to trigger a Jquery callback on a button click. This code below doesn't work because when the page is loaded Jquery doesn't found the "button.card" because it has not been loaded by progressive_render yet. How can I make it work?
<%=progressive_render do %>
<button class="card" />
<% end %>
$('.card').on('click', function(){
THIS NEVER GET TRIGGERED
})
The text was updated successfully, but these errors were encountered:
If you're writing this JavaScript in an asset that is loaded on page load (likely in rails!) then the jQuery code is binding on an object that doesn't yet exist. When you call $('.card') you're effectively returned a nil object that you're binding the event on, so it will never get fired. What you need to do is bind the event to an object that always exists, eg:
This gem is fantastic!
The only issue I have is to trigger a Jquery callback on a button click. This code below doesn't work because when the page is loaded Jquery doesn't found the "button.card" because it has not been loaded by progressive_render yet. How can I make it work?
The text was updated successfully, but these errors were encountered: