John Mcleod
2010-Jan-18 14:42 UTC
Disabling "Submit" button in form_remote_tag in dialog box
Hello all,
I have a jQuery dialog that renders a search form using
"form_remote_tag"
- _searchDialog.html.erb -
<div class=''confirmDialogMsg''>
Please type IRB number or part of a number<br />
If search does not retrieve desired results, please refine search.
</div>
<!-- Search Bar -->
<% form_remote_tag :update => "searchResults",
:url => {:controller => ''irbs'',
:action =>
''search''},
:position => "top",
:complete => "clearForm()" do -%>
<span class="search">
<%= text_field_tag :search, params[:search], :size => 30
%>
<%= submit_tag ''Search'', :class =>
''searchButton'' %>
</span>
<% end -%>
<!-- end Search Bar -->
IRB Number:
<div id="searchResults"></div>
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.
JohnM
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
John Mcleod
2010-Jan-18 15:42 UTC
Re: Disabling "Submit" button in form_remote_tag in dialog box
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;
jQuery(function(){
jQuery(''#add'').dialog({
title: ''Search IRB Records'',
position: [200,50],
width:''auto'',
resizable:false,
buttons: {
"Close":function() {
var value = "";
jQuery(''input[type=submit]'').removeAttr(''disabled'');
jQuery(''input#search'').val(value);
jQuery(''.searchResults'').empty();
jQuery(this).dialog(''destroy'');
}
},
error: function(){
alert(''Error'');
},
success: function(){
alert(''Success'');
}
}); // end jQuery dialog
});
} // end function
and in the dialog box I render a form using "form_remote_tag".
- _searchDialog.html.erb -
<!-- Search Bar -->
<% form_remote_tag :update => "searchResults",
:url => {:controller => ''irbs'',
:action => ''search''},
:html => { :name => "searchForm" },
:position => "top",
:complete => "clearForm()" do -%>
<span class="search">
<%= text_field_tag :search, params[:search], :size => 30 %>
<%= submit_tag ''Search'', :class =>
''searchButton'' %>
</span>
<% end -%>
<!-- end Search Bar -->
IRB Number:
<div id="searchResults"></div>
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(function(){
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.
JohnM
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.