mpen
mpen

Reputation: 282825

jQuery UI Datepicker: Align below label issue

http://jsfiddle.net/r7D2x/

I'm trying to use jQuery Datepicker on a label (<span>) instead of an input field. Here's the code:

// javascript 
$('#placeholder').datepicker({
    changeMonth: true,
    changeYear: true,
    showMonthAfterYear: true,
    showOn: 'button',
    buttonText: 'set',
    dateFormat: 'd-M-y',
    onSelect: function(dateText, inst) {
        var date = $(this).datepicker('getDate');
        var epoch = date.valueOf() / 1000;
        $('#value').val(epoch);
        $('#label').text(dateText);
    }
});
(function() {
    var initial = 1297800000;
    var $label = $('#label');
    if (initial == '' || initial == '0') {
        $label.text('not set');
    } else {
        var date = new Date(initial * 1000);
        $label.text($.datepicker.formatDate('d-M-y', date));
    }

})();

<!-- html -->
<span id="label" /><:input_nulldate></span>
<input type="hidden" id="placeholder" />
<input type="hidden" id="value"  />

But I can't get it to popup under the <span>. It keeps popping up over the button instead. How can I get it to align correctly?

Upvotes: 4

Views: 6044

Answers (1)

Daniel Ahrnsbrak
Daniel Ahrnsbrak

Reputation: 1077

You can move the box around using css. For instance:

.ui-datepicker { 
  margin-left: -80px;
  margin-top: 40px

}

Will get it about where you want it.

Upvotes: 3

Related Questions