Adrian
Adrian

Reputation: 5681

how to add datepicker in custom tooltip

I can't figure out how to add a datepicker (jquery datepicker: http://jqueryui.com/datepicker/) to a custom tooltip.

The way I create the tooltip contents is by concatenating some strings on the fly:
contents += 'test1' + '<input type="text" id="datepicker" >';

The problem is that I need to attach the actual date picker to my input field with id datepicker:

$("#datepicker").datepicker();

This doesn't work because contents is not part of the DOM yet.

Any ideas how to overcome this? Thanks

Upvotes: 0

Views: 326

Answers (1)

Danyel Cabello
Danyel Cabello

Reputation: 777

Declare

var picker = $('<input type="text" id="datepicker" >');
picker.click(function(){
    picker.datepicker();
});

And then

contents += 'test1';
//domElement is your tooltip content 
domElement.html(contents);
domElement.append(picker);

Upvotes: 1

Related Questions