Skip to content

Commit

Permalink
Minor adjustments for the content option to display html.
Browse files Browse the repository at this point in the history
  • Loading branch information
uziel-bueno committed Jul 24, 2018
1 parent e0b860f commit 599c479
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
23 changes: 11 additions & 12 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,17 @@ For a general information alert, just do: `alert('Some message');` (same as `ale
First register the middleware in web middleware groups by simply adding the middleware class `UxWeb\SweetAlert\ConvertMessagesIntoSweetAlert::class` into the $middlewareGroups of your app/Http/Kernel.php class:

```php
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
...
\UxWeb\SweetAlert\ConvertMessagesIntoSweetAlert::class,
],

'api' => [
'throttle:60,1',
],
];
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
...
\UxWeb\SweetAlert\ConvertMessagesIntoSweetAlert::class,
],

'api' => [
'throttle:60,1',
],
];
```

> Make sure you register the middleware within the 'web' group only.
Expand Down Expand Up @@ -186,7 +186,6 @@ Finally, to display the alert in the browser, you may use (or modify) the view t
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="css/sweetalert.css">
</head>
<body>

Expand Down
4 changes: 3 additions & 1 deletion src/views/alert.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<script>
@if (Session::has('sweet_alert.content'))
var config = {!! Session::pull('sweet_alert.alert') !!}
config.content = document.createElement('div').innerHtml = config.content;
var content = document.createElement('div');
content.insertAdjacentHTML('afterbegin', config.content);
config.content = content;
swal(config);
@else
swal({!! Session::pull('sweet_alert.alert') !!});
Expand Down
4 changes: 3 additions & 1 deletion src/views/alert.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<script>
{% if session_has('sweet_alert.content') %}
var config = {!! Session::pull('sweet_alert.alert') !!}
config.content = document.createElement('div').innerHtml = config.content;
var content = document.createElement('div');
content.insertAdjacentHTML('afterbegin', config.content);
config.content = content;
swal(config);
{% else %}
swal({!! Session::pull('sweet_alert.alert') !!});
Expand Down

0 comments on commit 599c479

Please sign in to comment.