Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery UI - Cannot change month/year in datepicker within Modal Dialog

Using Datepicker inside a modal Dialog, don't work the Change Month/Year dropdown in Firefox 19.0.2 see:

http://jsfiddle.net/469zV/2/

HTML

<div id="dialog-form" title="test" style="display:none">
  <form>
     <fieldset>
        <p>Date1: <input type="text" id="datepicker"/></p>  
     </fieldset>
  </form>
</div>

SCRIPT

$( "#dialog-form" ).dialog({
    modal: true
});

$("#datepicker").datepicker({
    changeMonth: true,
    changeYear: true
});

After search a lot can find some info about this problem but nothing about solution:

http://bugs.jqueryui.com/ticket/8989#no1

How do I solve this?

like image 254
Alex Abreu Mulet Avatar asked Jan 27 '26 05:01

Alex Abreu Mulet


2 Answers

You need to blur out of the textbox after picking a date so it can re-trigger the focus event:

$( "#dialog-form" ).dialog({
    modal: true
});

$("#datepicker").datepicker({
    changeMonth: true,
    changeYear: true    
}).on('change',function(){
                 $(this).blur()
               });
like image 124
mr.freeze Avatar answered Jan 28 '26 19:01

mr.freeze


This may not be exactly what you were looking for, but if you drop the text input, it will give you the month and year selection back.

Working Example

$( "#dialog-form" ).dialog({  
    modal:true,
    height:340,
    width:340
});

$("#datepicker").datepicker({
    changeMonth: true,
    changeYear: true,

});

<div id="dialog-form" title="test" style="display:none"> 
    <form>
    <fieldset> 
        <div id="datepicker"/></div>  
    </fieldset>
    </form>
</div>
like image 45
apaul Avatar answered Jan 28 '26 20:01

apaul



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!