Hi, I create some checkboxs with check_box_tag in a rhtml, when I check the checkbox, I change the css class of the checkbox with javascript, everything is fine, however, when I press on F5 to refresh my page, the checkbox is still checked, but the css class is turned back to the uncheck... What happens exactly when I press F5? Is the rhtml page rebuilt??? or what, and where the checkbox information is stored (since it has kept its checked state) in params, session or ...? Thanks you very much Sayoyo -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom
2007-Feb-27 17:06 UTC
Re: how do I know checkbox if a checkbox is checked after F5?
> I create some checkboxs with check_box_tag in a rhtml, when I check the > checkbox, I change the css class of the checkbox with javascript, > everything is fine, however, when I press on F5 to refresh my page, the > checkbox is still checked, but the css class is turned back to the > uncheck... What happens exactly when I press F5? Is the rhtml page > rebuilt??? or what, and where the checkbox information is stored (since > it has kept its checked state) in params, session or ...?Is this firefox? I''ve noticed that reloads will cause the edits to the form you''ve made since initial load to be kept, isntead of the form resetting itself. If that''s what you''re experiencing, then click in the url bar and just hit return. That seems to cause it to not only reload, but reset the form as well. -philip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
javier ramirez
2007-Feb-27 17:06 UTC
Re: how do I know checkbox if a checkbox is checked after F5?
> checkbox is still checked, but the css class is turned back to the > uncheck... What happens exactly when I press F5? Is the rhtml page > rebuilt??? or what, and where the checkbox information is stored (since it has kept its checked state) in params, session or ...? >when you press F5 you will usually get a new petition of the page to the server. It depends on browser cache configuration anyway. Maybe images are not reloaded and .js by default wouldn''t either, but rails appends a chunk of numbers to gracefully reload js without wiping the cache. So, when the server gets the new petition it will reload the action and, as you say, ''rebuild'' the rhtml (assuming you are in development environment and didn''t change the defaults). About the client side values, such as the selected check boxes, it''s your browser the one populating the values again after hitting F5. On Firefox you can force a full reload with Ctrl+F5, and not sure if on IE was Shift+F5. good luck, javier ramirez -- -------- Estamos de estreno... si necesitas llevar el control de tus gastos visita http://www.gastosgem.com !!Es gratis!! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Chris Hall
2007-Feb-27 17:38 UTC
Re: how do I know checkbox if a checkbox is checked after F5?
use some javascript. prototype has some nice functionality to get at form elements var checkboxes = $(''form_id'').getInputs(''checkbox''); checkboxes.each(function(cb) { if (cb.checked == true) { // if using class attribute Element.addClassName(cb, ''checked_class''); // or if using style attribute // Element.setStyle(cb, {''backgroundColor'':''#FF0000''}) } }); or something to that effect. On 2/27/07, Philip Hallstrom <rails-SUcgGwS4C16SUMMaM/qcSw@public.gmane.org> wrote:> > > I create some checkboxs with check_box_tag in a rhtml, when I check the > > checkbox, I change the css class of the checkbox with javascript, > > everything is fine, however, when I press on F5 to refresh my page, the > > checkbox is still checked, but the css class is turned back to the > > uncheck... What happens exactly when I press F5? Is the rhtml page > > rebuilt??? or what, and where the checkbox information is stored (since > > it has kept its checked state) in params, session or ...? > > Is this firefox? I''ve noticed that reloads will cause the edits to the > form you''ve made since initial load to be kept, isntead of the form > resetting itself. If that''s what you''re experiencing, then click in the > url bar and just hit return. That seems to cause it to not only reload, > but reset the form as well. > > -philip > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks you for all the information!!!! Yes, I''m using firefox on linux fedora core 5. I have try to ctrl+F5, but it seems not to reload anything.... thanks for the hint for javascript code, but I wonder if ruby can do the same thing..... like detecting if F5 is pressed??? Thanks you very much!!!! Sayoyo -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Chris Hall
2007-Feb-27 21:36 UTC
Re: how do I know checkbox if a checkbox is checked after F5
no, the server has no way to know you pressed ''F5''. as already discussed, the steps involved are: 1) initial page load 2) you check some checkboxes off, and your styles are applied (assuming you use an onClick event) 3) you press F5, telling browser to request the page again 4) page is (re)loaded 5) your browser, remembering what you did in the form, repopulates the form. NOTE: no onclick events are fired when your browser repopulates the form. the next step if for you to write some javascript to set the styles on the checkboxes that have been checked by the browser. see the example i provided to you. On 2/27/07, sayoyo <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Thanks you for all the information!!!! > > Yes, I''m using firefox on linux fedora core 5. I have try to ctrl+F5, > but it seems not to reload anything.... > > thanks for the hint for javascript code, but I wonder if ruby can do the > same thing..... like detecting if F5 is pressed??? > > Thanks you very much!!!! > > Sayoyo > > > -- > 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-/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 -~----------~----~----~----~------~----~------~--~---
Russell Norris
2007-Feb-28 13:19 UTC
Re: how do I know checkbox if a checkbox is checked after F5
Let''s not forget that there''s more than one shortcut for reloading a page. CTRL + "R", SHIFT + CTRL + "R", maybe more. RSL On 2/27/07, sayoyo <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Thanks you for all the information!!!! > > Yes, I''m using firefox on linux fedora core 5. I have try to ctrl+F5, > but it seems not to reload anything.... > > thanks for the hint for javascript code, but I wonder if ruby can do the > same thing..... like detecting if F5 is pressed??? > > Thanks you very much!!!! > > Sayoyo > > > -- > 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-/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 -~----------~----~----~----~------~----~------~--~---
alexey.Creopolis
2007-Mar-01 13:44 UTC
Re: how do I know checkbox if a checkbox is checked after F5?
Good day, i dont get why u need to do this but you can use session to store newly checked checkboxes even if user not pressed Submit. just make onclick event for each checkbox(javascript), that insert to session coookie id of checkbox. <input type="checkbox" onclick="doRemember(this.id)" /> function doRemember(domID) { PUT small verification code to determine wheither checkbox are checked or not if checked call Set_Cookie("checkbox_" + domID, 1); if unchecked call Set_Cookie("checkbox_" + domID, 0); } function Set_Cookie(name,value) { var cookieString = name + "=" +escape(value); document.cookie = cookieString; } <---------------------> okay, now when u reload page and running in loop of some model just check session cookie with "checkbox_?" names, split it by "_" and if somemodel.id = ? (of checkbox, and checkbox_? 1) then html attribute of this will be checked="checked" Make something that will make hash of all cookie checkboxes like: checkboxes ... [id, value] [id, value] values will be 0 or 1 and id will be value after checkbox_? Offcourse you should run another loop inside instance loop, to check all checkbox_? cookies. box.each do | box | attrib = "" checkboxes.each do | checkbox | attrib = "checked=" if checkbox.id == box.id checkbox.value == 1 ? attrib += "''checked''" : attrib +"''none''" end end end ---------------------- Thats all for now, maybe i made somewhere mistake, didnt checked it, but it should work. On Feb 27, 6:50 pm, sayoyo <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, > > I create some checkboxs with check_box_tag in a rhtml, when I check the > checkbox, I change the css class of the checkbox with javascript, > everything is fine, however, when I press on F5 to refresh my page, the > checkbox is still checked, but the css class is turned back to the > uncheck... What happens exactly when I press F5? Is the rhtml page > rebuilt??? or what, and where the checkbox information is stored (since > it has kept its checked state) in params, session or ...? > > Thanks you very much > > Sayoyo > > -- > Posted viahttp://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-/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 -~----------~----~----~----~------~----~------~--~---