Disabling "Submit" button in form_remote_tag in dialog box

Hello all,

I have a jQuery dialog that renders a search form using

  • _searchDialog.html.erb -
Please type IRB number or part of a number
If search does not retrieve desired results, please refine search.
<% form_remote_tag :update => "searchResults", :url => {:controller => 'irbs', :action => 'search'}, :position => "top", :complete => "clearForm()" do -%> <%= text_field_tag :search, params[:search], :size => 30 %> <%= submit_tag 'Search', :class => 'searchButton' %> <% end -%> IRB Number:

I can get the search results to display but my problem is if the user
clicks on the submit button twice the search will continue to add the
results to the “searchResults” div.

Then only answer is to either disable the submit button or somehow
disable the search feature.
I’ve tried using “:disable_with” to disable the submit button and it
didn’t work.

Thank you for any help on this.


Well, I answered this one on my own.

In my “applications.js” file, I have a function that opened the jquery
dialog box.

  • application.js -
    function addIrb(id){
    jQuery.ui.dialog.defaults.bgiframe = true;
    title: ‘Search IRB Records’,
    position: [200,50],
    buttons: {
    “Close”:function() {
    var value = “”;
    error: function(){
    success: function(){
    }); // end jQuery dialog
    } // end function

and in the dialog box I render a form using “form_remote_tag”.

  • _searchDialog.html.erb -

<% form_remote_tag :update => “searchResults”,
:url => {:controller => ‘irbs’, :action => ‘search’},
:html => { :name => “searchForm” },
:position => “top”,
:complete => “clearForm()” do -%>

<%= text_field_tag :search, params[:search], :size => 30 %>
<%= submit_tag ‘Search’, :class => ‘searchButton’ %>

<% end -%>

IRB Number:

When the search is performed, I disable the button by calling
clearForm() function on complete.

  • clearForm() in application.js -
    function clearForm(id){
    new Effect.SlideDown(‘searchResults’);
    jQuery(‘input[type=submit]’, this).attr(‘disabled’, ‘disabled’);

Then when the dialog is closed, ( “Close”:function()… )
I remove the “disabled” attribute. This way when you open the dialog box
again, the button is enabled.

Hope that helps someone with the same problem.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs