RenderPartial Form doesn't show Datepicker (kartik) calendar

Hi,

I know this seems like a common topic in this forum, but as far as I looked, most topics don’t provide a clear solution or the ones given don’t work or I might not implement them properly.

in short:
When using ajax to renderPartial() a form the fields with a widget such as DatePicker are not working.
I understood that renderPartial doesn’t run the registered javascript but that there are some workaround…
As many topics suggested, I set the 4th parameter to true when using RenderPartial like

return $this->renderPartial( ‘myForm’, [ ‘model’ => $model ], false, true);

but this didn’t change a thing.
Some others topics say we need to set an “id” to the div containing the datepicker in order to reload it using some JS.

in the partially rendered view :

<div class=“col-lg-3” id=“datepicker1”>

<?= $form->field($model, 'DATE')->widget(DatePicker::classname(), [.....]);?>

</div>

in the main view:

<script type=“text/javascript”>
$(document).ready(function() {
$(’#datepicker1’).datepicker(‘destroy’);
$(’#datepicker1’).datepicker();
});
</script>

what I did, but this still doesn’t work. and I’m not sure how to implement this.

Of course, using renderAjax() would fix this issue but this is not what I want as renderAjax create more trouble for me as it generated the whole form when i just want to get the input as does renderPartial

thank you for your help and enlightment :slight_smile:

There is no one to enlight me ?
How can I able the datepicker to show up the calendar after rendering a form with a renderPartial ?

Thanks