Noah Daniels
2006-Apr-22 15:08 UTC
[Rails] RJS, scriptaculous, page.replace problem with input fields?
I''m hoping someone can help... I have an rjs template that invokes a couple of page.remove() calls that work fine, and a page.replace() call that does not. I''ve played with the javascript extensively from within Firefox''s FireBug module, and it seems to me that this is what is happening: What I''m trying to replace is an element that''s been generated by a check_box_tag call. So basically it''s an element like this: <input id="thumb_check_237" name="thumb_check_237" type="checkbox" checked="checked" value="1" /> and I''m trying to replace it with this: <input id="thumb_check_237" name="thumb_check_237" type="checkbox" value="1" /> to basically uncheck the checkbox. What seems to be happening is that page.replace() does not work correctly on single tags (like <input /> and <br />) but works fine on ''outer'' tags like <li> </li>. Does anyone have any idea what''s going on here, or why this is happening, or a workaround? many thanks! -- Posted via http://www.ruby-forum.com/.
Alex Wayne
2006-Apr-22 20:35 UTC
[Rails] Re: RJS, scriptaculous, page.replace problem with input fiel
Noah Daniels wrote:> I''m hoping someone can help... > > I have an rjs template that invokes a couple of page.remove() calls that > work fine, and a page.replace() call that does not. > > I''ve played with the javascript extensively from within Firefox''s > FireBug module, and it seems to me that this is what is happening: > > What I''m trying to replace is an element that''s been generated by a > check_box_tag call. So basically it''s an element like this: > > <input id="thumb_check_237" name="thumb_check_237" type="checkbox" > checked="checked" value="1" /> > > and I''m trying to replace it with this: > > <input id="thumb_check_237" name="thumb_check_237" type="checkbox" > value="1" /> > > to basically uncheck the checkbox. What seems to be happening is that > page.replace() does not work correctly on single tags (like <input /> > and <br />) but works fine on ''outer'' tags like <li> </li>. > > Does anyone have any idea what''s going on here, or why this is > happening, or a workaround? > > many thanks!You could change the state of the checkbox with javascript. You dont really need to replace single tags, and should instead just be changing their attributes. Try: page["thumb_check_#{check_box_id}"].checked = false which should generate: $("thumb_check_237").checked = false; -- Posted via http://www.ruby-forum.com/.