On Aug 29, 1:27 pm, Dave Castellano <li...@ruby-forum.com> wrote:
> Hi,
>
> Anybody know why :onchange works here...
> <%= select_tag "Minisections",
> options_from_collection_for_select(@minisections, :id, :title, :selected
> => @minisection.id), {:onChange => "{alert('Minisection has been changed
> to x !')}"} %>
>
> but NOT here (to call a function)...
> <script type="text/javascript">
> function xyz() {
> "{alert('Minisection has been changed to x !')}"}
> </script>
>
Because all that function does is create a string literal - it's not
actually calling alert because all that is enclosed in "".
Fred
> <%= select_tag "Minisections",
> options_from_collection_for_select(@minisections, :id, :title, :selected
> => @minisection.id),
> {:onChange => "xyz()"} %>
>
> The function is at the top of the .html.erb page. I have used a similar
> format with :onclick and it works fine.
>
> Thanks,
>
> DC
>
> --
> 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@googlegroups.com.
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.
No comments:
Post a Comment