简体   繁体   English

GROCERY CRUD日期选择器小部件?

[英]GROCERY CRUD date picker widget?

It is given that if your column type is date the form will show a date picker using the grocery crud. 假设您的列类型是日期,则该表格将使用杂货杂货显示日期选择器。 My problem is that, is it possible to use the date picker widget of the GROCERY CRUD (like displaying the date picker in the view and return the picked date)? 我的问题是,是否可以使用GROCERY CRUD的日期选择器小部件(例如在视图中显示日期选择器并返回所选择的日期)? If yes, how? 如果是,怎么办? An example will be appreciated. 一个例子将不胜感激。

It uses the jQuery UI DatePicker . 它使用jQuery UI DatePicker

So, assuming you have all of the same stylesheets and scripts included, in the view you want to use it on, as you do in the CRUD view, you can just use code like this (let's say your input field's id attribute is equal to "element"): 因此,假设您包含了所有相同的样式表和脚本,则在您要使用的视图中,就像在CRUD视图中一样,您可以只使用如下代码(假设您输入字段的id属性等于“元件”):

$("#element").datepicker();

Or, you can add a class to all of the elements you want to have date pickers (let's say date-picker ), and then run this JavaScript/jQuery: 或者,您可以将一个类添加到要具有日期选择器的所有元素中(例如, date-picker ),然后运行此JavaScript / jQuery:

$(document).ready(function(){
    $('.date-picker').datepicker();
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM