`
yezi
  • 浏览: 276034 次
  • 来自: 北京
社区版块
存档分类
最新评论

ROR中关于Calendar的使用

阅读更多
ror中可以很方便的使用与jsCalendar一样的控件:

该网页的地址http://dry.4thebusiness.com/info/dhtml_calendar

1、在工程文件的根目录下运行下面的更新
ruby script/plugin install http://dhtml-calendar.googlecode.com/svn/trunk


2、在.rhtml文件中置入:
<%= dhtml_calendar_includes %>

这样就可以使用Calendar控件了。一共有5个模式供用户选择:

1、弹出式:页面只有一个日历牌的图标,用户点击后,弹出控件:
<%= popup_calendar 'person', 'birthday',
	{ :class => 'date',
	  :field_title => 'Birthday',
	  :button_image => 'calendar.gif',
	  :button_title => 'Show calendar' },
	{ :firstDay => 1,
	  :range => [1920, 1990],
	  :step => 1,
	  :showOthers => true,
	  :cache => true }
%>


2、普通方式:日历完整显示在网页中:
<%= calendar 'person', 'birthday',
      { :class => 'date' },
      { :firstDay => 1,
        :range => [1920, 1990],
        :step => 1,
        :showOthers => true }
%>

3、输入框式:页面中显示一个输入框,鼠标点击后弹出日历供用户选择
<%= calendar_field 'person', 'birthday',
       { :class => 'date',
         :date => value,
         :field_title => 'Birthday',
         :button_title => 'Show calendar' },
       { :firstDay => 1,
         :range => [1920, 1990],
         :step => 1,
         :showOthers => true,
         :cache => true }
 %>

4、选择框式:页面显示一个标准的选择框和一个日历的图表,点击后弹出日历
<%= calendar_select 'person', 'birthday',
      { :class => 'date',
        :date => value,
        :field_title => 'Birthday',
        :button_title => 'Show calendar' },
      { :firstDay => 1,
        :range => [1920, 1990],
        :step => 1,
        :showOthers => true,
        :cache => true }
%>

5、box:页面显示一个输入框和一个日历图表,点击图标后显示一个日历
<%= calendar_box 'person', 'birthday',
       { :class => 'date',
         :date => value,
         :field_title => 'Birthday',
         :form_name => 'custform',
         :button_title => 'Show calendar' },
       { :firstDay => 1,
         :range => [1920, 1990],
         :step => 1,
         :showOthers => true,
         :cache => true }
 %>
分享到:
评论
1 楼 zxwilde 2007-11-19  
当我用radrails编译工具,使用该控件时,每当我关闭编译工具,然后打开,发现工程服务启动不了,通过检查,发现工程内 /public/images下多一个dhtml_calendar文件夹,它里面包含几张该控件使用到的图片. 究竟是不是它导致工程启动不了呢. 我将文件夹里的图片拷贝.然后,把它删除了,再次启动服务,启动成功.然后,我又关闭编译再打开,发现,dhtml_calendar文件夹又出现了.随后,我将它里面的图片拷贝到/public/images下,再将文件夹删除,再重新打开编译工具,发现dhtml_calendar文件夹就不出现了.问题解决.

相关推荐

Global site tag (gtag.js) - Google Analytics