`
myrev
  • 浏览: 163198 次
  • 性别: Icon_minigender_1
  • 来自: 福建
社区版块
存档分类
最新评论

Active Scaffold and JRails/jQuery

阅读更多
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')

2.  in your layout load both prototype and jquery

<%= javascript_include_tag ‘prototype’, ‘effects’, ‘jquery’ %>

3. 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
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics