jquery MonthYearDropdown - jquery-ui

I want show month and year in one dropdown on jQuery datetimepicker above the month/year navbar. Is there any way to do this?

To show month and year you can use default options like this:
$( "#datepicker" ).datepicker({changeMonth: true,changeYear: true});
but if you mean you want to show month and year in single dropdown (like jan-2011, feb-2011) then you will need to hack it and add a new dropdown and fill it will all allowed months-years. You will probably want to set minDate and maxDate values.

Related

Grails:How to disable dates in calendar plugin

I' have 2 text fields 1st one for giving date from and the other one for date to, what i want is while i'm selecting date from using 'calendar:datePicker' the dates before current date must be disabled and if i have selected a date 1/6/2014 in 1st text field, when i select the date to from the 2nd one the dates before 1/6/2014 must be disabled how can i achive this..?
From<calendar:datePicker name="datefrom" years="${2014..2017}" value="${new Date()}" defaultValue="${new Date()}"/>
To<calendar:datePicker name="dateto" years="${2014..2017}" value="${new Date()}" defaultValue="${new Date()}"/>
That looks like an old plugin and it might not have the option that you need.
Use jQuery UI instead: http://jqueryui.com/datepicker/#date-range
jQuery UI has a grails plugin as well. http://grails.org/plugin/jquery-ui

JQuery UI Datepicker currently displayed months

Im using datepicker in div with this configuration"
$("#homeDatepicker").datepicker({
numberOfMonths: 3,
dateFormat: 'dd-mm-yyyy',
firstDay: '1'
...
});
how do i know which monts are currently displayed in div (user can navigate to display next and previous one).
i want to load some external data using ajax depending on this data.
As indicated in this link http://jqueryui.com/datepicker/#multiple-calendars
The current month based on today's date and followed by next two months are displayed.

Date Output in Rails using jquery ui

I have a form where you click in start_date and a jquery calendar comes up to pick the date. I want to display the date as (ex.) September 25, 2012, but I also need rails to comprehend the correct start date not just output it correctly.
What do i need to add to this?
<%= feed_item.start_date %>
events.js.coffee
jQuery ->
$('#event_start_date').datepicker
dateFormat: 'yy-mm-dd'
$('#event_end_date').datepicker
dateFormat: 'yy-mm-dd'
Take a look at the altField and the altFormat options for the datepicker.
You can store the Rails-friendly date in a hidden field and pass it to the controller, and display the user-friendly field to the user.
EDIT
Take a look at this answer for an example on how to work with altField and altFormat.

Rails and query datepicker, how to get date in field more tied to pop-up calendar

The text field and the pop-up are linked in that I can use the calendar and the field shows the correct value (or blank) initially.
But they are not linked in that the pop-up is always for the current month, not the month of the db field value.
= f.text_field :content_date, id: 'datepicker', size: 10
I tried adding ,value: #user.content_date but it didn't help.
My jquery is:
// jQueryUI Date Picker:
$(function (){
$(".datepick").datepicker({ dateFormat: "yy-mm-dd"});
});
I added the dateFormat per dimuch which seemed promising but it didn't help yet.
I also tried altFormat but it did't help.
You probably have different date formats in the datepicker and content_date field. Take a look at this fiddle http://jsfiddle.net/wKNXx/

Rails date_select as single pulldown instead of three?

The current date_select form helper in Rails creates three pulldown menus for selecting month, date, and year for a date. Is there away to instead have a single pulldown with a list of dates?
For example, a list of the next 30 days from "Jan 1, 2011" to "Jan 30, 2011"?
While not a select/pulldown control, an alternative option is the jQuery datepicker.
Using that, you could do this:
Your date field:
<%= f.text_field :some_date %> # => presume that element id is some_date_id
You can add a drop down calendar to it like this:
<script type="text/javascript">
$(function() {
$( "#some_date_id" ).datepicker();
});
</script>
Instead of writing a date_select_tag use a select_tag and provide it an array of dates.
select_tag "invoice_date", options_from_collection_for_select(#array_of_dates,:first,:first)
Not sure how you're using the form. Perhaps if you post that snippet, a more specific and correct answer can be provided.
If you need date_select to work differently, you need to override the helper and roll your own. If you just want a certain functionality in your app and not interested in changing Rails itself, go for the select_tag option.

Resources