How to bookmark an event in datepicker?

4

I have this code in javascript:

 $(function() {
      $("#calendario").datepicker({
        changeMonth: true,
        todayHighlight: true,
        changeYear: true,
        showOtherMonths: true,
        selectOtherMonths: true,
        dateFormat: 'dd/mm/yy',
        dayNames: ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado', 'Domingo'],
        dayNamesMin: ['D', 'S', 'T', 'Q', 'Q', 'S', 'S', 'D'],
        dayNamesShort: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb', 'Dom'],
        monthNames: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],
        ;
        monthNamesShort: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro']
      });
    });


<div id="calendario"> </div>

And only the div above to call the calendar.

How do I enter a value in datepicker ? Remembering that it has to be manageable, that is, it can register more than 1.

    
asked by anonymous 10.12.2015 / 12:23

1 answer

1

Come on, first thing, remove the semicolon causing syntax error [Line 12].

Now let's ask your questions:

How do I register a value in the datepicker?

When you talk about registration, it's a little broad, it might be two things in my view.

1 - Set a Default value:

$("#calendario").datepicker( "setDate", "10/12/2015" );

2 - Get a selected value:

onSelect: function() {
  var dateAsObject = $(this).datepicker('getDate'); // pega valor selecionado
  console.log(dateAsObject);
}

Example working on: Jsfiddle

But if you want to be selected in the same field several example dates 25/12/2015,26/12/2015 etc ... You will have to use a Plugin because this is not supported in the jQueryUI datepicker; (

One plugin you can use is: MultDatepicker

    
10.12.2015 / 13:17