How to hide a toggling page element by default

I have a link in an rhtml template:

<%= link_to_remote “Edit”, :url => {:action => :toggle_edit_campaign}
%>

that executes an action to toggle a page element (edit_campaign):

def toggle_edit_campaign
render :update do |page|
page.toggle :edit_campaign
end
end

Toggling works, but the edit_campaign element is visible by default
when the page loads. I would like it to be hidden by default, and
then toggle show, hide, show, hide, etc. when the above link_to_remote
is clicked. How does one do this (make the element hidden by default,
and toggle to visible on the first click)?

Thanks.

Hi,

If :edit_campaign is a div you do:

content

Cheers

Set style=‘display:none’ on the element as an attribute.

On Jan 9, 2008 4:13 PM, athem [email protected] wrote:

 page.toggle :edit_campaign


Ryan B.

Feel free to add me to MSN and/or GTalk as this email.

On Jan 8, 10:17 pm, Peter D. [email protected]
wrote:

Hi,

If :edit_campaign is a div you do:

content

Cheers


Posted viahttp://www.ruby-forum.com/.

Worked like a charm. For anyone trying to hide a toggling div, that’s
the solution. Thanks very much.

Here’s how the div looks: