Yii2 Autocoplete

I am trying to switch to Yii2. This was source attribute of TextAreaJuiAutoComplete widget

    'source'=>"js:function(request, response) {

        $.getJSON('".$url"', {

            term: extractLast(request.term)

        }, response);


This is not working in Yii2 with yii\jui\AutoComplete anymore and I can’t find out why. Can anyone give me a hint what is the cause?

If I put following code it works, but I want to use ajax calls instead.

'source' => [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby" ],

This code works, so I suspect there is something wrong with Yii2 AutoComplete



    $('#my-id' ).autocomplete({

        source: function(request, response){

            $.getJSON('".$url."', {term: extractLast(request.term)}, response);