`
andyhu1007
  • 浏览: 193954 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

Rails每周闲碎(九): JavaScript

阅读更多

1. Caching multiple javascript into one

 

    javascript_include_tag :all, :cache => true

    javascript_include_tag "prototype", "cart", "checkout", :cache => "shop"

 

2. jQuery

 

    jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript.

 

    Rails默认使用的ajax框架是prototype,结合prototype,Rails提供了一些非常方便的prototype helper方法,比如:remote_form等。如果在Rails中选择使用jQuery库,不用担心使用不了这些helper方法,因为jRails 为这些方法提供了jQuery版本。

 

    jRails is a drop-in jQuery replacement for Prototype /script.aculo.us on Rails. Using jRails, you can get all of the same default Rails helpers for javascript functionality using the lighter jQuery library.

 

   用jQuery实现的一些工具也很好用,比如greybox


 

3. prototype helper methods

 

    It's strong by providing lots of helper method like observe_field, with lots of options like :success, :condition, :before.

 

    如果使用JQuery,也不需要担心这些方法没法使用。JRails 为这些方法实现了JQuery版本。

 

4. jquery的$(document).ready()

 

    与window.onload的区别 : $(document).ready()是在DOM结构载入完后执行的,而window.onload是在所有文件 都加载完后执行的。

 

5. jquery的serialize

 

    Serializes a set of input elements into a string of data.   http://docs.jquery.com/Ajax/serialize

 

3
0
分享到:
评论
1 楼 netfork 2009-07-12  
又学到了不少,谢谢。

相关推荐

Global site tag (gtag.js) - Google Analytics