yii2-sweet-alert icon indicating copy to clipboard operation
yii2-sweet-alert copied to clipboard

Not initialize when page render

Open dzero1 opened this issue 6 years ago • 0 comments

I start to use this as a replacement to data-confirm alerts. So I noticed sweetalert-min.js is not loading and always say swal is not defined. So when I go through you doc and found should insert "echo Alert::widget();" but no luck. (But it work after if I create a alert with title)

Then I check you code found it happen with a title checking inside the "registerAssets()" in Alert.php. So I commented if statement. Then it's fine.

here the new code:

protected function registerAssets(){
       //if ($this->hasTitle()) {
            $view = $this->getView();
            AlertAsset::register($view);
            $js = "sweetAlert({$this->getOptions()}, {$this->callback});";
            $view->registerJs($js, $view::POS_END);
        //}
}

Check this and update.

Anyway, Thanks for the plugin.

dzero1 avatar Jan 02 '19 10:01 dzero1