开发者

How to Show/Hide a block of text with ruby on rails based on a button click or link click

I'm new to ruby on rails and i'm trying to figure out how to hide/show a block of text based on a clicking a button or a link.

I followed the example in this link:

http://www.davidthomas.net.au/2009/09/ruby-on-rails-howto-showhide-div/comment-page-1/#comment-441

However, there are three problems I've experienced

  1. I'm not sure how to apply the logic to a button/link instead of a check box, or if its possible. The problem is I don't know how to associate the click on the button or link to the action within the observer. Maybe i'm not understanding the syntax. With the Example, the :on => :selected gives the observer an parameter to work with in the accepted_terms method.

  2. I'm currently using eclipse with ruby on rails(aptana) and can only see the code working sometimes on the browser built into eclipse and sometimes not (have to reload the page to get the check box working). With normal browser like Chrome, clicking the check box has no effect what so ever. Is there some setting i'm doing wrong? Browser setting?

  3. Is there an easier way to do this then using the Observer_field method?

Thanks for any advise or links to 开发者_开发百科examples that will help, D


Send ajax request and update the particular area using partials.

like that

render :partial => "partial_name", :layout => false

partial name starts with underscore

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜