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 7887847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:41:11+00:00 2026-06-03T05:41:11+00:00

Having a data-confirm tag in a link in Rails 3 generates the unobstructive Javascript

  • 0

Having a data-confirm tag in a link in Rails 3 generates the unobstructive Javascript needed to have an alert for confirmation. For example:

<%= link_to "Destroy", @product, :confirm => "Are you sure?", :method => :delete %>

However, I would like to change this behaviour to the following:

Clicking a button changes its text to ‘Sure?’ and then the user has to click it again for the action to take place. (perhaps the text can even go back to normal after a timeout)

Where is the best place to change this behaviour in a Rails 3.1 application? (BTW, I’m using Twitter Bootstrap in case there is a better solution that can work nicely this that).

  • 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-03T05:41:13+00:00Added an answer on June 3, 2026 at 5:41 am

    So here is how you do it (this is based on Custom rails confirm box (with $.rails.confirm override))

    This goes in your application.js if you want (Rails 3.1)

    $.rails.confirm = function(message, element) 
    { 
        var state = element.data('state');
        var txt = element.text();
        if (!state)
        {
            element.data('state', 'last');
            element.text('Sure?');
            setTimeout(function()
            {
                element.data('state', null);
                element.text(txt);
            }, 2000);
            return false;
        }   
        else
        {
            return true;
        }
    };
    
    $.rails.allowAction = function(element) 
    {
        var message = element.data('confirm'),
            answer = false, callback;
        if (!message) { return true; }
    
        if ($.rails.fire(element, 'confirm')) 
        {
            // le extension.
            answer = $.rails.confirm(message, element);
            callback = $.rails.fire(element, 'confirm:complete', [answer]);
        }
        return answer && callback;
    };
    
    $.rails.handleLink = function(link) 
    {
        if (link.data('remote') !== undefined) 
        {
            $.rails.handleRemote(link);
        } 
        else if (link.data('method')) 
        {
            $.rails.handleMethod(link);
        }
    
        return false;
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have two sheets having data like this sheet1 : **A** **B** **C** 752
I have a dynamic json data having the format var cols= { columns :
I have often heard complaints against Java for not having unsigned data types. See
I am trying to share my app (link having data and metatags) with the
I am fetching some data having UTF8 collation ( utf8_unicode_ci ) from a MySQL
I'm having difficulties displaying data in a UITextView in iPhone programming. I'm analyzing incoming
I'm having trouble inserting data from one column to another within the same table.
I am having trouble passing data read from a text file to another class
I am having troubles passing data from the controller to the model in opencart(1.5.3).
The main problem I'm having is pulling data from tables, but any other general

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.