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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:52:22+00:00 2026-05-21T05:52:22+00:00

Back in Rails 2, there was a :condition option in link_to_remote which let you

  • 0

Back in Rails 2, there was a :condition option in link_to_remote which let you specify some javascript which had to return true or the remote request would not be send. However, in rails 3 it seems like this options has been removed.

What I want to do is have an ajax form, but it needs to undergo validation on the browser before it gets submitted (this is very non-standard validation). Essentially I need to be able to set some conditional javascript expression to prevent the form from being submitted if validation fails – the same as the :condition option from rails 2. Is there any way to achieve this same functionality again in rails 3?

I’m using mootools with the mootools version of rails.js. I looked through the mootools rails.js file and didn’t see anything which looked like it would let me specify some conditional javascript. Am I missing something?

*note: I just looked through the source for the default rails.js file written in prototype. In this file there are there the following lines:

var event = element.fire("ajax:before");
if (event.stopped) return false;

This looks like in the prototype version you can stop the request from being sent by listening to the “ajax:before” event and stopping the event in your listener. However, I can’t find anything like this in the mootools rails.js code, so maybe this is a bug in the mootools rails.js file?

  • 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-05-21T05:52:23+00:00Added an answer on May 21, 2026 at 5:52 am

    link_to_remote was deleted from Rails 3. It’s a link_to :remote => true now. And if you want to do some js validation, you can use something like this:

    <%= link_to "test", '/test', :id => "test-link", :remote => true  %>
    

    and add your validation in the application.js (in my example it’s Prototype. And it’s not a problem to do it with Mootools I guess):

    document.observe("dom:loaded", function() {
      $('test-link').observe('click', function(event){
        if your_validation_magic
          event.stop();
      });
    });
    

    update:
    Mootools has this event too:
    https://github.com/kevinvaldek/mootools-ujs/blob/master/Source/rails.js#L131

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any open source (or example) code for Ruby on Rails which can
Is there an equivalent to Ruby On Rails' redirect_to :back in ASP.NET MVC? What
I'm have a Ruby on Rails project which displays illustrations. There are category links
I have some serious issues deploying my rails 3 app. There isn't a post
I have an uploadify component, which sends the files back to rails application. The
I am using Amazon S3 to back up my Rails app's mysql database. And
I am trying to build a rails 3 back-end for a mobile application. However,
I'm building a Rails application using MongoDB as the back-end and MongoMapper as the
Back in my C/C++ days, coding an infinite loop as while (true) felt more
back in school, we wrote a compiler where curly braces had the default behavior

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.