I made a small fiddle demonstrating my issue here http://jsfiddle.net/LkqTU/33025/
the datepicker made using a component does not fire
below is my original post...
I am using the bootstrap 3 date time picker and it is working as follows.
html
<div data-bind="css: formControlCss">
<label class="control-label" for="earlyPickup">Early Pickup:</label>
<div class='input-group date' id='earlyPickup'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
javascript.
$('#earlyPickup').datetimepicker(
{
defaultDate: d.DB2VXRVSMRecord.DtErlstPickup + " " + d.DB2VXRVSMRecord.TiErlstPickup
});
this works fine however I have several of these date time pickers so I attempted to create a knockout component.
component.
ko.components.register('datetime-picker', {
viewModel: function (params) {
this.label = params.label
this.id = params.id
this.hasError = params.hasError
this.formControl = ko.pureComputed(function () {
return (this.hasError()) ? "form-group has-error" : "form-group";
}, this);
},
template:
'<div data-bind="css: formControl">\
<label class="control-label" \
data-bind ="attr: {for: id}"> \
<span data-bind="text: label"></span>:</label>\
<div class="input-group date"\
data-bind= "attr: {id: id}" >\
<input type="text" class="form-control" />\
<span class="input-group-addon">\
<span class="glyphicon glyphicon-calendar"></span>\
</span>\
</div>\
</div>'
});
and I changed my HTML to.
<datetime-picker
params="label: 'Early Pickup',
id: 'earlyPickup',
hasError: ErlstPickupHasErrors">
</datetime-picker>
unfortunately my date time picker is no longer instantiated. I am assuming because since I am now using a component I can not refer to id directly? when calling the date time picker $('#earlyPickup').datetimepicker(
does it not know what earlyPickup is at this point?