Date picker opens alone when changes neighbor input

1

Good morning, I have the following code:

var maxDate = new Date();
maxDate.setDate( maxDate.getDate() + 364);

$(".dtpBloqueio").datepicker( {
    numberOfMonths: 2,
    dateFormat: 'dd/mm/yy',
    maxDate: maxDate
});

When you change an input select that is inside the same as the date input, if so, maxDate is set as today.

<table>
    <tr>
        <td>
           <select name="datasLocalizaSv" id="listaDatasLocalizaSv"/>
        </td>   
        <td>
          <input id="dataComeco" name="dataComeco" class="dtpBloqueio"/>
        </td>
    </tr>
</table>

$(".dtpBloqueio").datepicker("change", { maxDate: new Date() } );

But every time I change the information in select the datapicker opens alone in the first input, except that it opens blank, as if it had used the "refresh". link

How can I make the datepicker not open by itself when I change something on the side of it?

    
asked by anonymous 03.09.2014 / 15:43

2 answers

1

I think your mistake is just in the code that changes the date. I looked in the documentation and there is no such option as change , so I think this is generating some event that is interpreted as a click. Try replacing this code with something like this:

$( ".dtpBloqueio" ).datepicker( "option", "maxDate", new Date() );
    
03.09.2014 / 15:57
1

I was able to solve this:

$( ".dtpBloqueio" ).datepicker('destroy');

and then I re-created datepicker :

$(".dtpBloqueio").datepicker( {
    numberOfMonths: 2,
    dateFormat: 'dd/mm/yy',
    maxDate: new Date()
});
    
03.09.2014 / 16:30