I have a remote_form which works 100%
When a user clicks submit, it goes out grabs so data from the db or data scraped from another website, and updates the page seamlessly...
The problem I'm having now, is that I'd like to do the same thing, but do it without having the user click the submit button with an onload event. I think I'm going about it the wrong way:
Technically this works... it does get the right data, but instead of doing exactly what the remote_form_tag does it returns the data raw. No RJS replace_html.
Is there a way to skip the form_for altogether and just execute the controller action directly when the page loads?
<script type="text/javascript">
$(window).load(function() {
// executes when HTML-Document is loaded and DOM is ready
// jQuery.facebox('Big loading! <img alt=\"Loading\" src=\"/images/loaders/loading.gif\" />');
//$("#update_form").submit();
$("#update_form").submit(function () { return false; });
});
</script>
The form for
#html.erb
<% form_remote_tag :url => { :action => "update_availables", :id => params[:id] },
:loading => "jQuery.facebox('Big loading! <img alt=\"Loading\" src=\"/images/loaders/loading.gif\" />');",
:html => { :method => "get" },
:method => "get",
:html => { :id => 'update_form' } do %>
The controller
def update_availables
@do_it = Available.get_new_availables :id => params[:id], :date => user_cart.getDate.to_s
get_availables
respond_to do |format|
format.html
format.js
end
end
RJS
page.replace_html :rooms, :partial => "available"
page << "jQuery.facebox.close();"