隨筆-167  評論-65  文章-0  trackbacks-0

          概述:用在rails平臺下的日期選擇插件

          我的環(huán)境:ruby1.8.6 + rails 2.1.0  + windows

          預覽:

          image

          使用方法:

          1,安裝插件

          gem install calendar_date_select

          2,在environment.rb 中添加

          config.gem "calendar_date_select"

          3,restart你的服務器

          4,在rhtml中使用

          <%= calendar_date_select_includes "silver",:locale=>'zh' # or "blue", or "silver", or nil for the default!
          %>

          <%= form_tag :action=>'new' %>
          日期:<%= calendar_date_select_tag "regdate", nil, :popup => "force" %><br/>
          <%= submit_tag '注冊'  %>
          <%= form_tag %>

          另外可以中文化,格式化等等...........

          中文化:

          在public的對應文件夾下的local下添加zh.js

          Date.weekdays = $w("一 二 三 四 五 六 七");
          Date.months = $w("一月 二月 三月 四月 五月 六月 七月 八月 九月 十月 十一月 十二月" );

          Date.first_day_of_week = 1

          _translations = {
            "OK": "確定",
            "Now": "現(xiàn)在",
            "Today": "今天",
            "Clear": "清除"
          }

           

          格式化:

          在environment.rb最后添加

          CalendarDateSelect.format = :iso_date

           

          源碼下載:

          http://www.namipan.com/d/d8ebbc8dda4c1aac18add209401fe1f2ccd67b4572b70100

          ref:

           http://code.google.com/p/calendardateselect/
           http://code.google.com/p/calendardateselect/wiki/HowToLocalize
           http://code.google.com/p/calendardateselect/wiki/ChangingDateFormat

          write by feng
          posted on 2009-04-08 17:48 fl1429 閱讀(604) 評論(0)  編輯  收藏 所屬分類: Rails
          已訪問數:
          free counters
          主站蜘蛛池模板: 双辽市| 沁阳市| 吴堡县| 大名县| 衡东县| 泸溪县| 安泽县| 肥乡县| 保康县| 晴隆县| 巍山| 武清区| 闵行区| 苗栗市| 崇礼县| 右玉县| 邵阳县| 汶川县| 盈江县| 西峡县| 昌乐县| 崇文区| 景谷| 津市市| 东宁县| 岐山县| 巫山县| 建昌县| 武夷山市| 阳原县| 都江堰市| 宿迁市| 天峻县| 桐乡市| 黑水县| 盐津县| 中阳县| 安义县| 商城县| 保康县| 莆田市|