Advertisement
artur99

Top Bar dropdown

May 24th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.58 KB | None | 0 0
  1. HTML
  2.  
  3.  
  4. <div class="dropdown notif-ico-cnt">
  5.     <a href="#" data-toggle="dropdown">
  6.         <img src="{% static 'icons/icon_notification.svg' %}" alt="" class="notif-ico">
  7.     </a>
  8.     <div class="dropdown-menu dropdown-menu-right movies-dropdown" style="width: 240px;">
  9.         <div class="list-group" id="booked-movies-list">
  10.             <!-- Will be filled by js -->
  11.         </div>
  12.     </div>
  13. </div>
  14.  
  15.  
  16. <script>
  17. $(document).ready(function(){
  18.     if($("#booked-movies-list")) {
  19.         populate_booked_movies()
  20.     }
  21. }
  22.  
  23. var populate_booked_movies = function() {
  24.     var loc = $("#booked-movies-list")
  25.     var html = '<div class="list-group-item">Booked movies:</div>';
  26.     $.get("/api/notifications")
  27.     .done(data => {
  28.         var els = data.tickets
  29.         if(els.length == 0){
  30.             html += '<div class="list-group-item"><em>No movies booked...</em></div>'
  31.         }
  32.        
  33.         for(var el of els){
  34.             html += `<a href="/movies/${el.movie_id}" class="list-group-item list-group-item-action">
  35.                 <img src="/media/${el.movie_photo}" class="movie_icon_drd">
  36.                 <b>${el.movie_name}</b><br>
  37.                 <span>${el.show_datetime}</span>
  38.             </a>`
  39.         }
  40.         loc.html(html)
  41.     })
  42. }
  43. </script>
  44.  
  45.  
  46.  
  47. <style>
  48.  
  49. .movies-dropdown {
  50.     padding: 0!important;
  51.     border: 0!important;
  52.     max-height: 300px;
  53.     overflow-y: auto;
  54. }
  55. .movies-dropdown .movie_icon_drd {
  56.     float: left;
  57.     width: 23px;
  58.     height: auto;
  59.     vertical-align: middle;
  60.     margin-right: 9px;
  61.     margin-top: 8px;
  62. }
  63. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement