六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 38|回复: 0

Rails每周闲碎(九): JavaScript

[复制链接]

升级  9.67%

67

主题

67

主题

67

主题

举人

Rank: 3Rank: 3

积分
229
 楼主| 发表于 2013-1-23 02:46:11 | 显示全部楼层 |阅读模式
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 HTMLdocument traversing, event handling, animating, and Ajax interactionsfor rapid web development. jQuery is designed to change the way that you write JavaScript.
 
    Rails默认使用的ajax框架是prototype,结合prototype,Rails提供了一些非常方便的prototypehelper方法,比如: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
 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表