protected function registerJs()
    {
        $config['options'] = $this->options;
        $config['layerOptions'] = $this->layerOptions;
        $config['layerOptions']['layerId'] = $this->layer->getLayerId();

        $config = Json::encode($config);
        $layerClass = Json::encode($this->layerClass);

        $this->view->registerJs("
            $.ajaxSetup({
                showNoty: true // default for all ajax calls
            });
            $(document).ajaxComplete(function (event, xhr, settings) {
                if (settings.showNoty && (settings.type=='POST' || settings.container)) {
                    $.ajax({
                        url: '$this->url',
                        method: 'POST',
                        cache: false,
                        showNoty: false,
                        global: false,
                        data: {
                            layerClass: '$layerClass',
                            config: '$config'
                        },
                        success: function(data) {
                           $('#" . $this->layer->getLayerId() . "').html(data);
                        }
                    });
                }
            });
        ", View::POS_END);
    }