RJS, scriptaculous, page.replace problem with input fields?


#1

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:

and I’m trying to replace it with this:

to basically uncheck the checkbox. What seems to be happening is that
page.replace() does not work correctly on single tags (like
and
) but works fine on ‘outer’ tags like

  • .

    Does anyone have any idea what’s going on here, or why this is
    happening, or a workaround?

    many thanks!


    #2

    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:

    and I’m trying to replace it with this:

    to basically uncheck the checkbox. What seems to be happening is that
    page.replace() does not work correctly on single tags (like
    and
    ) but works fine on ‘outer’ tags like

  • .

    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;