javascript - Show Bootstrap popover only once -


i've got jsfiddle: http://jsfiddle.net/jsfiddleplayer/vhg7csb7/3/

when load page , click on "blog" tab, should show popover 5.6 seconds , disappear. if user clicks on tab , returns "blog", should not show popover again. should once per user visit page.

currently, shows popover every time visit "blog" tab. i've looked @ this post (configuring bootstrap popover appear once?), destroy method doesn't seem work me.

here's html:

<div class="r1 row" id="anch-story">     <div class="c1 col-md-12">         <ul class="nav nav-justified nav-tabs">             <li class="active">                 <a class="btn-lg" data-toggle="tab" href="#story-tab-1">vision</a>             </li>             <li>                 <a class="btn-lg" data-toggle="tab" href="#story-tab-2">manufacturing</a>             </li>             <li>                 <a class="btn-lg" data-toggle="tab" href="#story-tab-3">press</a>             </li>             <li>                 <a class="btn-lg" data-toggle="tab" href="#story-tab-4">blog</a>             </li>         </ul>         <div class="tab-content">             <div class="tab-pane fade in active" id="story-tab-1">             </div>             <div class="tab-pane fade" id="story-tab-2">             </div>             <div class="tab-pane fade" id="story-tab-3">             </div>             <div class="tab-pane fade" id="story-tab-4">                 <div id="page-selection" class="text-center">                     <ul class="pagination bootpag pagination-lg">                         <li data-lp="1" class="prev disabled"> <a href="javascript:void(0);">                                 &#xf0d9;                             </a>                         </li>                         <li data-lp="1" class="active"> <a href="javascript:void(0);">1</a>                          </li>                         <li data-lp="2"> <a href="javascript:void(0);">2</a>                          </li>                         <li data-lp="2" class="next"> <a href="javascript:void(0);">                                 &#xf0da;                             </a>                         </li>                     </ul>                 </div>                       </div>         </div>     </div> </div> 

here's jquery:

$(document).ready(function(){     $('#page-selection > ul').attr('title', 'blog post navigation')         .attr('data-content', 'use these controls , navigate blog posts.')         .attr('data-placement', 'bottom')         .attr('data-toggle','popover');        $('a[href="#story-tab-4"]').on('shown.bs.tab', function (e) {         $('#page-selection > ul').popover('show');            window.settimeout(function () {             $('#page-selection > ul').popover('destroy');             }, 5600);     });      $('body').on('click', function (e) {         $('[data-toggle=popover]').each(function () {             // hide open popovers when anywhere else in body clicked             if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {                 $(this).popover('destroy');             }         });     }); }); 

here's css:

.next > {     font-family:'fontawesome';     content:"\f0d9"; } .prev > {     font-family:'fontawesome';     content:"\f0da"; } .prev > a, .next > {     font-size: 2.3em !important;     max-height: 47px !important;     padding-top: 2px !important;  } 

maybe can add simple logic check if popover has been shown or not.

something this:

$('a[href="#story-tab-4"]').on('shown.bs.tab', function (e) {      if($(this).data('popover-shown')) return;      $(this).data('popover-shown', true);      $('#page-selection > ul').popover('show');       ... 

demo: http://jsfiddle.net/alan0xd7/vhg7csb7/5/


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -