rails 4 can only call javascript once from link_to -


I have a list with which I want to delete using javascript and want to hide the row.

The experience I have is that if I click on a link, then removes the item and the row disappears. If I make a second click, the controller is not asked, the pages Just refresh via javascript.

show.html.erb

  link_to image_tag ("bin-20.png",: border => 0), '#',: title = & Gt; 'Remove this item', data: {deleteitem: item.id} item.js.coffee $ - & gt; $ ("One [data-delete]") Click - & gt; $ (This) .data ("deletemem") $ .jax type: "POST" url: urllink Data type: "Jason" data: _method: $ (divclass). Toggle () Warning ("The item has been removed from your list")  

If I click on a link and the second one. The output I get in the console is:

  Post http://local-dev.com:3000/itemisations/636 200 OK 1.6s jquery.js? Body = 1 (line 9632) Http://local-dev.com:3000/items/60# 200 OK 7.88 S. Turboli ... ... body = 1 (line 59) receive http: // local-dev. Com: 3000 / items / 60 # 200 OK 8.31s  

Then I can see that the first time the call runs on the systemmatroler on the system and then shows the view. However, the controller is not able to call on the second click ...

Oh, and the reason I'm running a link directly to the controller rather than running a link instead of the country script. Be able to toggle call

OK, it seems as if I got wrong Turbolink here To solve the problem, I changed my script to

  $ (document)'Ready page: Load', - & gt; $ ("One [data-delete]") Click - & gt; $ (This) .data ("deletemem") $ .jax type: "POST" url: urllink Data type: "JSN" data: _method: $ (divclass). The tagl () warning ("items have been removed from your list") "delete"  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -