DataCCIW

Search Settings - PageListAsBlocks

Dec 22nd, 2021 (edited)
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.19 KB | None | 0 0
  1. {%- comment -%}
  2.    Last Update: 1-6-22
  3.    Summary: Adds search functionality to the PageListAsBlocks lava template
  4. {%- endcomment -%}
  5.  
  6. {%- javascript -%}
  7. $(document).ready(function()
  8. {
  9.     // Prevent async page submission triggered by enter key which breaks script, preventing submission after keyup does not work
  10.     $('#pageSearch').on('keydown', function(e)
  11.     {
  12.  
  13.         if (e.keyCode == 13)
  14.         {
  15.             e.preventDefault();
  16.             return false;
  17.         }
  18.     });
  19.  
  20.     // Filter page links when Search box is updated, value of text is not updated until after keyup
  21.     $('#pageSearch').on('keyup', function(e)
  22.     {
  23.         var value = $(this).val().toLowerCase();
  24.         $('.panel-body ul li').filter(function()
  25.         {
  26.             $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1);
  27.         });
  28.     });
  29. });
  30. {%- endjavascript -%}
  31.  
  32. {%- stylesheet -%}
  33.     #pageSearch { margin-bottom:15px; }
  34. {%- endstylesheet -%}
  35.  
  36. <div class="form-inline">
  37.     <div class="form-group">
  38.         <input id="pageSearch" type="text" class="form-control input-sm" placeholder="Search&hellip;">
  39.     </div>
  40. </div>
  41.  
  42. {%- include '~~/Assets/Lava/PageListAsBlocks.lava' -%}
Add Comment
Please, Sign In to add comment