yii2-sweet-alert
yii2-sweet-alert copied to clipboard
Not initialize when page render
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.