Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8395939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:25:16+00:00 2026-06-09T20:25:16+00:00

I have a delete link in Rails: <%= link_to #{image_tag(icons/icon_delete.png, :alt => Delete)} Delete.html_safe,

  • 0

I have a delete link in Rails:

<%= link_to "#{image_tag("icons/icon_delete.png", :alt => "Delete")} Delete".html_safe, "#suppliers", id: supplier.id, class: "delete", :title => "Delete", :confirm => 'Are you sure?', :method => :delete %>

And I have a backbone event that catches it (CofeeScript):

  events: ->
    "click a.delete": "deleteSupplier"

  deleteSupplier: (event) ->
    event.preventDefault()
    console.log("delete")

All of this works fine, except that when I click OK on the confirm dialog, the link is followed. Any ideas how to prevent this? If I return false from deleteSupplier the confirmation no longer works which isn’t quite what I’m after. I’d like the confirmation to work, just not follow through the link when I click OK.

EDIT: I forgot to mention that these links are inserted after the page is loaded through an ajax get request. And I also tested by removing the :confirm and it doesn’t seem to make any difference. I believe it has something to do with being loaded through the ajax request, but I would have thought that the event would not even fire if that were the case 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:25:17+00:00Added an answer on June 9, 2026 at 8:25 pm

    You are playing with two forces: the Rails magic link who adds JS handlers to the link and the Backbone who also adds handlers to the link.

    You better go with one and give the day free for the other. As you are using Backbone as your JS weapon let’s move all the JS logic to Backbone:

    <%= link_to "delete", "#suppliers", :id => supplier.id, :class => "delete", :title => "Delete" %>
    
    deleteSupplier: function( event ) {
      event.preventDefault();
      if( confirm( "Are you sure?" ) ) {
        console.log("delete")
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi i have this starnge behavoir... <%= link_to image_tag(image.png), brain_path(1), :method => put %>
I have simple delete link: = link_to Delete, messages_path(message.id), :method => :delete Gives me
So, I have the following link-to: <%= link_to(outing_add_guests_path, :class => 'modal') do %> <div
I want to have a delete user link in a normal Activerecord table, but
I'm working with Ruby on rails 2.3.4 and I'd like to have a link
With rails 2.3.8 I had = link_to 'old_Delete', link_path(@link), :confirm => 'Are you sure?',
I have two links: <%= link_to(Edit, edit_product_path(product.id)) %> <%= link_to(Delete, product, :method => :delete)
I want to have a Delete-link on a page viewing an object in my
How do you perform delete and put operations restfully in rails? I have read
I currently have the following link_to in my Rails application: <%= link_to 'Remove this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.