ITeye博客

Active Scaffold and JRails/jQuery

myrev · 2010-07-29 19:58 · Rails · 编程语言 · Markdown

To use Active with scaffold with JRails you have to use a different

JQUERY_VAR than $

In our controllers

  1. set
ActionView::Helpers::PrototypeHelper::JQUERY_VAR = ‘jQuery’

or

ActionView::Helpers::PrototypeHelper.const_set(:JQUERY_VAR, 'jQuery')

  1. in your layout load both prototype and jquery
<%= javascript_include_tag ‘prototype’, ‘effects’, ‘jquery’ %>

  1. Lastly, make sure to tell jQuery to not conflict with Prototype over $ in your Javascript:

application.html.erb


  <script type="text/javascript">
      jQuery.noConflict();
    </script>

Now, you should use "jQuery()" instead of "$()".

eg:


jQuery("#id").hide()

http://errtheblog.com/posts/73-the-jskinny-on-jquery

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。