Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

定时关闭问题 #11

Open
luopeihai opened this issue Jul 6, 2018 · 0 comments
Open

定时关闭问题 #11

luopeihai opened this issue Jul 6, 2018 · 0 comments

Comments

@luopeihai
Copy link

实现效果:定时关闭alert,
Alert 代码:
........
echo \yii2mod\alert\Alert::widget([
'useSessionFlash' => false,
'options' => [
'timer' => null,
'type' => $type,
'title' => $message,
'timer'=> 1500,
// 'showConfirmButton'=> false
]
]);
.......
发现并没有自动关闭,查看 源码 yii2mod/yii2-sweet-alert/Alert.php文件

......
protected function registerAssets()
{
if ($this->hasTitle()) {
$view = $this->getView();
AlertAsset::register($view);
//var_dump($this->getOptions());exit;
$js = "sweetAlert({$this->getOptions()}, {$this->callback});";
$view->registerJs($js, $view::POS_END);
}
}
.......
把 $js = "sweetAlert({$this->getOptions()}, {$this->callback});"; 改为
$js = "sweetAlert({$this->getOptions()});";
定时效果搞定

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant