-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
40 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/** | ||
* | ||
* @author xjflyttp <xjflyttp@gmail.com> | ||
*/ | ||
|
||
namespace xj\bootbox; | ||
|
||
use \Yii; | ||
use yii\web\AssetBundle; | ||
|
||
class BootboxOverrideAsset extends BootboxAsset | ||
{ | ||
|
||
public static function register($view) | ||
{ | ||
$view->registerJs(' | ||
yii.confirm = function(message, ok, cancel) { | ||
bootbox.confirm(message, function(result) { | ||
if (result) { !ok || ok(); } else { !cancel || cancel(); } | ||
}); | ||
} | ||
'); | ||
|
||
if (Yii::$app->language !== null && strlen(Yii::$app->language) >= 2) { | ||
$view->registerJs('bootbox.setDefaults({locale: "' . substr(Yii::$app->language, 0, 2) . '"});'); | ||
} | ||
|
||
return parent::register($view); // TODO: Change the autogenerated stub | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bc40401
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your solution still requires call
BootboxOverrideAsset::register($this);
in layout.Look at my solution:
and AppAsset:
It is no need to register bundle in layout!
bc40401
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.