当前位置: 首页 > 工具软件 > jRails > 使用案例 >

Active Scaffold and JRails/jQuery

蔺德曜
2023-12-01
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
 类似资料: