On Feb 22, 11:26 am, Adam Akhtar <[email protected]>
wrote:
> Im incorporating ajax / javascript stuff for the first time in my
> project and im a bit confused by all various methods available, rjs,
> prototype, javascript etc so please excuse me if this is an obvious
> question.
>
> Whilst looping though an array of model objects in my view I want to be
> able to show or hide a div that contains the message "Your list is
> empty".
>
> so something like this
>
> <% if items.empty?>
> #the following is not the correct way
> $('no-items-msg').show
> <% else >
> $('no-items-msg').hide
> <% items.each do |item|%>
> render :partial => "item_rows"......
> <%end%>
First off in javascript the () for function calls is mandatory - $('no-
items-msg').show just evaluates to a function object, you need $('no-
items-msg').show() to actually call it. secondly your javascript needs
to be inside <script> tags (there's a rails helper that will assist
with this, can't remember what it's called but it has javascript in
the name.
Fred
>
> how do i add the prototype stuff correctly?
> --
> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---