Problem with spinner image on form_remote_tag

Problem:

View Code:-->

<% form_remote_tag :url => get_reports_backend_billing_billing_reports_path,:update => "reports", :complete => "Element.hide('../images/spinner.gif')", :loading => "Element.show('../images/spinner.gif')" do %>     <label>         Select Status:     </label>     <%= select_tag "status",options_for_select(Report::STATUS.collect.insert(0,'')) %>     <%= submit_tag 'Get Reports' %>     <% end %>

Controller code:- def reports reports = Report.find_reports(params[:status])     @reports = reports.first     if request.post?       render :update do |page|         page.replace_html "reports_table",:partial => 'reports'     end    end end

Here form is working fine when i am selecting status .. but when i click on submit spinner image is not coming ...

Suppose if i am using :disable_with in the submit_tag it is giving RJS error.

Why? Could any help me!!!!!!

Thanks in advance

what version of rails are you using?

Lorenzo Brito Morales wrote in post #983527:

what version of rails are you using?

2.3.5

Problem:

View Code:-->

<% form_remote_tag :url => get_reports_backend_billing_billing_reports_path,:update => "reports", :complete => "Element.hide('../images/spinner.gif')", :loading => "Element.show('../images/spinner.gif')" do %> <label> Select Status: </label> <%= select_tag "status",options_for_select(Report::STATUS.collect.insert(0,'')) %> <%= submit_tag 'Get Reports' %> <% end %>

Controller code:- def reports reports = Report.find_reports(params[:status]) @reports = reports.first if request.post? render :update do |page| page.replace_html "reports_table",:partial => 'reports' end end end

Here form is working fine when i am selecting status .. but when i click on submit spinner image is not coming ...

Install Firebug in Firefox and see whether it throws up any errors when you click the button.

Colin

Colin Law wrote in post #983543:

</label>   render :update do |page|    page.replace_html "reports_table",:partial => 'reports' end end end

Here form is working fine when i am selecting status .. but when i click on submit spinner image is not coming ...

Install Firebug in Firefox and see whether it throws up any errors when you click the button.

Colin

Presently firebug is installed in my system. i have already tested it. it is not throwing any error. But when i am using :disable_with in submit_button it is throwing RJS Error on web page .. Like below format

try { Element.update("reports_table", "<table class=\"list\">\n <n RE_PAID\\n </td>\\n <td>\\n NONE\\n </td>\\n <td>\\n NONE\\n </td>\\n <td>\\n \\n </td>\\n <td>\\n 20\\n </td>\\n </tr>\\n \\n <tr id =\\\"row_3\\\" class=\\\"list_item odd\\\" onclick=\\\"highlightLine(row_3)\\\">\\n <td>\\n <td>\\n </td>\\n </tr>\\n \\n \\n </tbody>\\n</table>\\n\");'); throw e }

Problem:

View Code:–>

<% form_remote_tag :url =>

get_reports_backend_billing_billing_reports_path,:update => “reports”,

:complete => “Element.hide(‘…/images/spinner.gif’)”, :loading =>

“Element.show(‘…/images/spinner.gif’)” do %>

<label>

    Select Status:

</label>

<%= select_tag

“status”,options_for_select(Report::STATUS.collect.insert(0,‘’)) %>

<%= submit_tag 'Get Reports' %>

<% end %>

There’s something wrong with your :loading and :complete arguments. I think Element.hide and Element.show

expects an element id. change it to

:complete => ‘$(“spinner”).hide();’

:loading => ‘$(“spinner”).show()’

then add this where you like the image to show

image_tag ‘/images/spinner.gif’, :id => ‘spinner’

Jim ruther Nill wrote in post #983573:

   </label>    <%= select_tag "status",options_for_select(Report::STATUS.collect.insert(0,'')) %>    <%= submit_tag 'Get Reports' %>    <% end %>

There's something wrong with your :loading and :complete arguments. I think Element.hide and Element.show expects an element id. change it to

:complete => '$("spinner").hide();' :loading => '$("spinner").show()'

then add this where you like the image to show

image_tag '/images/spinner.gif', :id => 'spinner'

Thanks in advance For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

--

Hi Jim ruther Nill

Thank You For Suggestion

It is working fine with little bit modification

I have place this information in form_remote_tag as

<% form_remote_tag(:url => { :action=>"get_reports" } ,:before => "$('spinner').show();", :complete => '$("spinner").hide();') do %>

Here i placed my code.....

<% end %>

So Here i am using these :before => '$("spinner").show();',

:complete => '$("spinner").hide();')

i have defined a div called below

<div id="spinner"> <%= image_tag "../images/spinner.gif" %> </div>

Now it is working fine ..............

But if suppose i am using :loading instead of :before it is not showing spinning image....

Why? What is the reason? Ant one Have Any Idea?