Autocomplete Widget in Ajax Area

I have a Problem with a Autocomplete Field in an Ajax Area. This is my Autocomplete Widget wich is working if i load the complete Page. But the Widget is in an Area, which will be reloaded by Ajax (i didn’t use Pjax). After this reload, the Widget is not working anymore.

How can i solve this?

Thank!


<?= $form->field($suche, 'text')

                    ->label(false)

                    ->widget(\yii\jui\AutoComplete::classname(), [

                'options' => ["placeholder"=>"Suchen..."],

                'clientOptions' => [

                    'autoFill' => true,

                    'minLength' => '2',

                    'source' => "/site/typesearch",

                    'select' => new JsExpression("

                        function( event, ui ) {

                            $(this).submit();

                      }"),

                ],

                ]) ?>

OK, here is the Solution: If you use AJAX to load your pages and there is a Autocomplete Plugin inside: This will not work. You have to manually init the Plugin after your Ajax Call like this

// Reactivate Autocomplete after AJAX


 if (jQuery('#websearchform-text').autocomplete!==undefined) {

                    jQuery('#websearchform-text').autocomplete({

                        "autoFill":true,

                        "minLength":"2",

                        "source":"/site/typesearch",

                        "select":

                            function( event, ui ) {

                                $("#websearchform-text").submit();

                          }

                });