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 :: what is typescript 
Typescript :: ts declare function type 
Typescript :: curl send 100 requests parallel 
Typescript :: argument of type * is not assignable to parameter of type SetStateAction 
Typescript :: Error: Missing "key" prop for element in iterator 
Typescript :: ts log array to console 
Typescript :: How to define functional component types 
Typescript :: get enum key typescript 
Typescript :: sorting a vector of objects c++ 
Typescript :: Generate module in ionic 4|5|6 
Typescript :: react native typescript issue 
Typescript :: enable anchor scrolling angular 
Typescript :: multer s3 
Typescript :: amcharts angular universal 
Typescript :: latex two plots in 1 
Typescript :: google sheets mode text 
Typescript :: navigate in new tab with query params angular 
Typescript :: useformik type for typescript 
Typescript :: convert node to typescript 
Typescript :: react-excel-renderer nextjs error 
Typescript :: arrow function in ts 
Typescript :: conditional styled components with media query 
Typescript :: create npm module typescript 
Typescript :: verify if object is of a certain type type in typescript 
Typescript :: how to find specific elements from a list in java 
Typescript :: when a vector in c++ is resized what happens to the elements of the vector 
Typescript :: typeorm decrement 
Typescript :: make a type in typescript 
Typescript :: listen to server sent events flutter 
Typescript :: typescript string 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =