Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

use toasts in django

    {% if messages %}
        {% for message in messages %}
            {% if message.tags == 'success'%}
                <script type=text/javascript>toastr.{{ message.tags }}('{{ message }}')</script>
            {% elif message.tags == 'info' %}
                <script type=text/javascript>toastr.{{ message.tags }}('{{ message }}')</script>
            {% elif message.tags == 'warning' %}
                <script type=text/javascript>toastr.{{ message.tags }}('{{ message }}')</script>
            {% elif message.tags == 'error' %}
                <script type=text/javascript>toastr.{{ message.tags }}('{{ message }}')</script>
            {% endif %}
        {% endfor %}
    {% endif %}
Comment

use toasts in django

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="{% static 'css/toastr.css' %}" media="all">
<script type="text/javascript" src="{% static 'js/toastr.min.js' %}"></script>  
Comment

download toasts in django

{% for message in messages %}
  <div class="toast notification bg-{% if message.tags == 'error' %}danger{% else %}{{message.tags}}{% endif %}" role="alert" aria-live="assertive" aria-atomic="true" data-delay="5000">
    <div class="toast-header">
      <strong class="mr-auto">
        {% if message.tags == 'error' %}
          <i class="fas fa-times mr-2"></i>
        {% elif message.tags == 'warning' %}
          <i class="fas fa-exclamation mr-2"></i>
        {% elif message.tags == 'info' %}
          <i class="fas fa-info mr-2"></i>
        {% elif message.tags == 'success' %}
          <i class="fas fa-check mr-2"></i>
        {% endif %}
        {{message.tags|capfirst}}
      </strong>
      <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
        <span aria-hidden="true">×</span>
      </button>
    </div>
    <div class="toast-body">
      {{message|safe}}
    </div>
  </div>
{% endfor %}
Comment

download toasts in django

...
{% include 'message.html' %}
...


<!-- and at the end:-->
<script src="{% static 'js/jquery-3.4.1.min.js' %}"></script>
<script src="{% static 'js/bootstrap.min.js' %}"></script>
{% if messages %}
  <script>
      {% for message in messages %}
          $(document).ready(function () {
              $('.toast').toast('show');
          });
      {% endfor %}
  </script>
{% endif %}
Comment

download toasts in django

.notification{
    position: absolute;
    top: 5rem;
    right: 1rem;
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: file reader with promise 
Typescript :: pytest tests in subfolder 
Typescript :: compare two lists and find at least one equal python 
Typescript :: mongodb move documents to another collection 
Typescript :: typescript string 
Typescript :: void function typescript 
Typescript :: why important testng xml file 
Typescript :: TypeScript Example Code Snippet 
Typescript :: data type of stack in c 
Typescript :: react native styled-components responsive font 
Typescript :: c# to typescript 
Typescript :: react functional components setstate callback 
Typescript :: typescript dynamic interface 
Typescript :: react typescript append to array 
Typescript :: testing techniques 
Typescript :: typescript 
Typescript :: inheritance problem in Dart 
Typescript :: Can only use lower 16 bits for requestCode registerForActivityResult 
Typescript :: requests get with sign in 
Typescript :: ts(2503) 
Typescript :: how t make fireball roblox or lua 
Typescript :: Associate of Arts in Broadcast Media Arts 
Typescript :: Using TypeScript generic with `...rest` operator 
Typescript :: how-to-pass-data-between-middleware 
Typescript :: How to pass multiple route parameters in Ionic-Angular? 
Typescript :: whats the extension of a markup language 
Typescript :: exclude redults after theninclude 
Typescript :: scale a vector 
Typescript :: “There does not exist a woman who has taken a flight on every airline inthe world.” 
Typescript :: reverse a string if its value its greater than 3 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =