ABPrime ABPrime - 1 year ago 86
Javascript Question

ajax closest is not affected in ruby on rails

Hello I am newbie in ruby on rails.And I try to do some ajax in my demo website.Delete is performed but I have to refresh each time.


%li{id: feed_item.id}
= image_tag current_user.image_url(:small_thumb).to_s
%b Source:
= feed_item.source
%b Destination:
= feed_item.destination
%b Date:
= feed_item.date
%b Time:
= feed_item.time
%b Comment:
= feed_item.content
- if current_user == feed_item.user
= link_to "Delete", feed_item ,method: :delete, data: { confirm: "You sure?" }, title: "Delete", remote: true, class: "delete_post"


$('.delete_post').bind('ajax:success',function() {


def destroy
respond_to do |format|
format.html { redirect_to root_url, notice: "Post deleted" }
format.js { render nothing: true}

raw html link


Thanks in Advance.

Answer Source

The reason why jquery not working. problem is turbolinks. $(document).ready(function() is not working with turbolinks. for more look this description

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download