Forum: Ruby on Rails field update not happneing

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Parker T. (Guest)
on 2005-12-15 23:29
(Received via mailing list)
Hi,

I'm having some scriptaculous weirdness, hoping this is an easy fix.  I
have a js function defined in my header:

function flash(msg){
   $('flash_msg').value = msg;
   alert(msg);  // for debugging
   ...
}

This is being called like so:

<%= form_remote_tag(
     :update => 'admins',
     :url => { :action => 'add_admin', :params => {:id => @place.id} },
     :complete => "flash('passes msg'); = \$('add_field').value = '';"
     )
%>

When I hit 'Add' the correct div is updated, I see the alert (saying
"passed message"), and 'add_field' is cleared, but 'flash_msg' never
gets
set.  There are no js errors and I'm just totally stumped over why this
could be.

Thanks in advance for any help,

pt.
------
Parker T.
Professional
(w) http://placesite.com
(c) 510.541.0125
Mark Reginald J. (Guest)
on 2005-12-16 01:56
(Received via mailing list)
Parker T. wrote:

> function flash(msg){
>   $('flash_msg').value = msg;
>   alert(msg);  // for debugging
>
> When I hit 'Add' the correct div is updated, I see the alert (saying
> "passed message"), and 'add_field' is cleared, but 'flash_msg' never
> gets set.  There are no js errors and I'm just totally stumped over why
> this could be.

What kind of HTML element has the flash_msg id?

--
We develop, watch us RoR, in numbers too big to ignore.
Parker T. (Guest)
on 2005-12-16 02:11
(Received via mailing list)
On Fri, 16 Dec 2005, Mark Reginald J. wrote:

|What kind of HTML element has the flash_msg id?

Ah, figured it out (thanks).  I was trying to replace the contents of a
div (also tried a span) using .value.  Switching to innerHTML, e.g.:

  $('flash_msg').innerHTML = msg;

fixed the problem.  I knew it had to be something silly, just needed my
assumptions questioned, thanks.

pt.
This topic is locked and can not be replied to.