I have 2 button_to functions that download 2 different files. the first one acts like a submit and the second on actually does downlaod the file. Does anyone know what would cause that? <%= button_to ''Download PCCIS file'', :action => ''downloadpccis'' %> <%= button_to ''Download CIS file'', :action => ''downloadcis'' %> --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Anyone have any idea why one button does a submit and the other does a file download? On Feb 11, 9:36 pm, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have2button_tofunctionsthat download2different files. the > first one acts like a submit and the second on actually does downlaod > thefile. Does anyone know what would cause that? > > <%=button_to''Download PCCISfile'', :action => ''downloadpccis'' %> > <%=button_to''Download CISfile'', :action => ''downloadcis'' %>--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Thu, 2009-02-12 at 17:29 -0800, Me wrote:> Anyone have any idea why one button does a submit and > the other does a file download?In general, element behavior in any page is a function of the browser parser''s ability to make sense of the code we feed it. Post your code and we might be able to help. Best regards, Bill --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Application.rhtml:
<% form_tag( {:action => ''mltn6p''} ) do -%>
<div id="page">
<div id="header">
<h1>Wendia Site entry Program</h1>
</div>
<div id="menu">
<fieldset>
<legend>Select your Shelf</legend>
<%= select(:node, :id, $shelves,{:prompt =>''Select
Equipment''},{
:onchange => remote_function(:url => { :action =>
"gotoshelf"})} ) %>
</fieldset><br />
<%= render :partial => ''sitedata'' %>
<fieldset id="downloads" style="display:
none">
<legend>Download POB Files</legend>
<%= button_to ''Download CIS file'',
:action =>
''downloadcis'' %>
<%= button_to ''Download PCCIS file'',
:action =>
''downloadpccis'' %>
</fieldset>
</div>
<div id="content">
<div id="notification"> </div>
<%= yield %>
</div>
</div>
<% end %>
controller:
def downloadcis
send_file("#{$site.upcase}_CIS.csv", :type =>
''text/plain'',
:disposition => ''attachment'')
end
def downloadpccis
send_file("#{$site.upcase}_PCCIS.csv", :type =>
''text/plain'',
:disposition => ''attachment'')
end
On Thu, Feb 12, 2009 at 9:24 PM, bill walton
<bwalton.im-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>
> On Thu, 2009-02-12 at 17:29 -0800, Me wrote:
> > Anyone have any idea why one button does a submit and
> > the other does a file download?
>
> In general, element behavior in any page is a function of the browser
> parser''s ability to make sense of the code we feed it. Post your
code
> and we might be able to help.
>
> Best regards,
> Bill
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
For some reason the first button is giving me this for a response:
try {
$("notification").update("<h1 style=''display:
inline'' class=''mes''>Site
123 was built</h1>");
$("downloads").show();
} catch (e) { alert(''RJS error:\n\n'' + e.toString());
alert(''$
(\"notification\").update(\"<h1 style=\''display:
inline\'' class=\''mes
\''>Site 123 was
built</h1>\");\n$(\"downloads\").show();''); throw
e }
On Feb 12, 9:45 pm, Chris Habgood
<chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Application.rhtml:
> <% form_tag( {:action => ''mltn6p''} ) do -%>
> <div id="page">
> <div id="header">
> <h1>Wendia Site entry Program</h1>
> </div>
> <div id="menu">
> <fieldset>
> <legend>Select your Shelf</legend>
> <%= select(:node, :id, $shelves,{:prompt
=>''Select Equipment''},{
> :onchange => remote_function(:url => { :action =>
"gotoshelf"})} ) %>
> </fieldset><br />
> <%= render :partial => ''sitedata'' %>
> <fieldset id="downloads" style="display:
none">
> <legend>Download POB Files</legend>
> <%= button_to ''Download CIS file'',
:action =>
> ''downloadcis'' %>
> <%= button_to ''Download PCCIS file'',
:action =>
> ''downloadpccis'' %>
> </fieldset>
> </div>
>
> <div id="content">
> <div id="notification"> </div>
> <%= yield %>
> </div>
> </div>
> <% end %>
>
> controller:
> def downloadcis
> send_file("#{$site.upcase}_CIS.csv", :type =>
''text/plain'',
> :disposition => ''attachment'')
> end
>
> def downloadpccis
> send_file("#{$site.upcase}_PCCIS.csv", :type =>
''text/plain'',
> :disposition => ''attachment'')
> end
>
> On Thu, Feb 12, 2009 at 9:24 PM, bill walton
<bwalton...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > On Thu, 2009-02-12 at 17:29 -0800, Me wrote:
> > > Anyone have any idea why one button does a submit and
> > > the other does a file download?
>
> > In general, element behavior in any page is a function of the browser
> > parser''s ability to make sense of the code we feed it. Post
your code
> > and we might be able to help.
>
> > Best regards,
> > Bill
>
>
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Anyone have any ideas why the second button works but the first button is giving me the above error? On Feb 12, 10:27 pm, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> For some reason the first button is giving me this for a response: > try { > $("notification").update("<h1 style=''display: inline'' class=''mes''>Site > 123 was built</h1>"); > $("downloads").show();} catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''$ > > (\"notification\").update(\"<h1 style=\''display: inline\'' class=\''mes > \''>Site 123 was built</h1>\");\n$(\"downloads\").show();''); throw e } > > On Feb 12, 9:45 pm, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Application.rhtml: > > <% form_tag( {:action => ''mltn6p''} ) do -%> > > <div id="page"> > > <div id="header"> > > <h1>Wendia Site entry Program</h1> > > </div> > > <div id="menu"> > > <fieldset> > > <legend>Select your Shelf</legend> > > <%= select(:node, :id, $shelves,{:prompt =>''Select Equipment''},{ > > :onchange => remote_function(:url => { :action => "gotoshelf"})} ) %> > > </fieldset><br /> > > <%= render :partial => ''sitedata'' %> > > <fieldset id="downloads" style="display: none"> > > <legend>Download POB Files</legend> > > <%=button_to''Download CISfile'', :action => > > ''downloadcis'' %> > > <%=button_to''Download PCCISfile'', :action => > > ''downloadpccis'' %> > > </fieldset> > > </div> > > > <div id="content"> > > <div id="notification"> </div> > > <%= yield %> > > </div> > > </div> > > <% end %> > > > controller: > > def downloadcis > > send_file("#{$site.upcase}_CIS.csv", :type => ''text/plain'', > > :disposition => ''attachment'') > > end > > > def downloadpccis > > send_file("#{$site.upcase}_PCCIS.csv", :type => ''text/plain'', > > :disposition => ''attachment'') > > end > > > On Thu, Feb 12, 2009 at 9:24 PM, bill walton <bwalton...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > On Thu, 2009-02-12 at 17:29 -0800, Me wrote: > > > > Anyone have any idea why one button does a submit and > > > > the other does afiledownload? > > > > In general, element behavior in any page is a function of the browser > > > parser''s ability to make sense of the code we feed it. Post your code > > > and we might be able to help. > > > > Best regards, > > > Bill > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
OK Well this must be a bug I guess but I managed to get it to work. For some reason the first one was trying to give the js response to the action. So for the hey of it I used 3 button_to''s and the bottom two worked while the first one was giving me the same response. <div style="display: none;"><%= button_to ''Download PCCIS file'', :action => ''downloadpccis'' %></div> <%= button_to ''Download PCCIS file'', :action => ''downloadcis'' %> <%= button_to ''Download PCCIS file'', :action => ''downloadpccis'' %> On Feb 13, 6:22 pm, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Anyone have any ideas why the second button works but the first button > is giving me the above error? > > On Feb 12, 10:27 pm, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > For some reason the first button is giving me this for a response: > > try { > > $("notification").update("<h1 style=''display: inline'' class=''mes''>Site > > 123 was built</h1>"); > > $("downloads").show();} catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''$ > > > (\"notification\").update(\"<h1 style=\''display: inline\'' class=\''mes > > \''>Site 123 was built</h1>\");\n$(\"downloads\").show();''); throw e } > > > On Feb 12, 9:45 pm, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Application.rhtml: > > > <% form_tag( {:action => ''mltn6p''} ) do -%> > > > <div id="page"> > > > <div id="header"> > > > <h1>Wendia Site entry Program</h1> > > > </div> > > > <div id="menu"> > > > <fieldset> > > > <legend>Select your Shelf</legend> > > > <%= select(:node, :id, $shelves,{:prompt =>''Select Equipment''},{ > > > :onchange => remote_function(:url => { :action => "gotoshelf"})} ) %> > > > </fieldset><br /> > > > <%= render :partial => ''sitedata'' %> > > > <fieldset id="downloads" style="display: none"> > > > <legend>Download POB Files</legend> > > > <%=button_to''Download CISfile'', :action => > > > ''downloadcis'' %> > > > <%=button_to''Download PCCISfile'', :action => > > > ''downloadpccis'' %> > > > </fieldset> > > > </div> > > > > <div id="content"> > > > <div id="notification"> </div> > > > <%= yield %> > > > </div> > > > </div> > > > <% end %> > > > > controller: > > > def downloadcis > > > send_file("#{$site.upcase}_CIS.csv", :type => ''text/plain'', > > > :disposition => ''attachment'') > > > end > > > > def downloadpccis > > > send_file("#{$site.upcase}_PCCIS.csv", :type => ''text/plain'', > > > :disposition => ''attachment'') > > > end > > > > On Thu, Feb 12, 2009 at 9:24 PM, bill walton <bwalton...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Thu, 2009-02-12 at 17:29 -0800, Me wrote: > > > > > Anyone have any idea why one button does a submit and > > > > > the other does afiledownload? > > > > > In general, element behavior in any page is a function of the browser > > > > parser''s ability to make sense of the code we feed it. Post your code > > > > and we might be able to help. > > > > > Best regards, > > > > Bill > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Feb-14 17:58 UTC
Re: SUCCESS!! BUG?? Re: 2 button_to functions for file downloads
On Feb 14, 5:54 pm, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> OK Well this must be a bug I guess but I managed to get it to work. >button_to generates a form for you with a button. You''ve put a button in a form, therefore in the generated html there will be a form nested inside a form which isn''t valid html (and also sorts of weird stuff can happen, like the "wrong" form being generated). Fred> For some reason the first one was trying to give the js response to > the action. So for the hey of it I used 3 button_to''s and the bottom > two worked while the first one was giving me the same response. > > <div style="display: none;"><%= button_to ''Download PCCIS file'', > :action => ''downloadpccis'' %></div> > <%= button_to ''Download PCCIS file'', :action => ''downloadcis'' %> > <%= button_to ''Download PCCIS file'', :action => ''downloadpccis'' %> > > On Feb 13, 6:22 pm, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Anyone have any ideas why the second button works but the first button > > is giving me the above error? > > > On Feb 12, 10:27 pm, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > For some reason the first button is giving me this for a response: > > > try { > > > $("notification").update("<h1 style=''display: inline'' class=''mes''>Site > > > 123 was built</h1>"); > > > $("downloads").show();} catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''$ > > > > (\"notification\").update(\"<h1 style=\''display: inline\'' class=\''mes > > > \''>Site 123 was built</h1>\");\n$(\"downloads\").show();''); throw e } > > > > On Feb 12, 9:45 pm, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Application.rhtml: > > > > <% form_tag( {:action => ''mltn6p''} ) do -%> > > > > <div id="page"> > > > > <div id="header"> > > > > <h1>Wendia Site entry Program</h1> > > > > </div> > > > > <div id="menu"> > > > > <fieldset> > > > > <legend>Select your Shelf</legend> > > > > <%= select(:node, :id, $shelves,{:prompt =>''Select Equipment''},{ > > > > :onchange => remote_function(:url => { :action => "gotoshelf"})} ) %> > > > > </fieldset><br /> > > > > <%= render :partial => ''sitedata'' %> > > > > <fieldset id="downloads" style="display: none"> > > > > <legend>Download POB Files</legend> > > > > <%=button_to''Download CISfile'', :action => > > > > ''downloadcis'' %> > > > > <%=button_to''Download PCCISfile'', :action => > > > > ''downloadpccis'' %> > > > > </fieldset> > > > > </div> > > > > > <div id="content"> > > > > <div id="notification"> </div> > > > > <%= yield %> > > > > </div> > > > > </div> > > > > <% end %> > > > > > controller: > > > > def downloadcis > > > > send_file("#{$site.upcase}_CIS.csv", :type => ''text/plain'', > > > > :disposition => ''attachment'') > > > > end > > > > > def downloadpccis > > > > send_file("#{$site.upcase}_PCCIS.csv", :type => ''text/plain'', > > > > :disposition => ''attachment'') > > > > end > > > > > On Thu, Feb 12, 2009 at 9:24 PM, bill walton <bwalton...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > On Thu, 2009-02-12 at 17:29 -0800, Me wrote: > > > > > > Anyone have any idea why one button does a submit and > > > > > > the other does afiledownload? > > > > > > In general, element behavior in any page is a function of the browser > > > > > parser''s ability to make sense of the code we feed it. Post your code > > > > > and we might be able to help. > > > > > > Best regards, > > > > > Bill--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---