Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Short version: use the pjax:end event to apply bootstrap behavior to new elements.</p> <p>When pjax loads the new content, the bootstrap handlers haven't been bound to all of the elements. With typical jQuery elements, you can use 'live' to have jQuery detect new content and apply the correct handlers. Sorry if this first part is stuff you already know.</p> <p>For example if this is in your jQuery ready function:</p> <pre><code>$('a').click(function() { alert('here') } </code></pre> <p>If you dynamically load content containing another anchor element, the click handler won't be bound to it.</p> <p>But if you do this:</p> <pre><code>$('a').live('click', function() { alert('here') } </code></pre> <p>when the new content is loaded, jQuery will add the click handler because it's bound using live.</p> <p>Back to bootstrap. For something like a popover, there is no equivalent 'live' method as far as I can tell. You can't change this:</p> <pre><code>$('a').popover() </code></pre> <p>to this:</p> <pre><code>$('a').live('popover') # WON'T WORK </code></pre> <p>So if the anchor is loaded via pjax (or ajax or anything dynamic), any new anchors aren't bound as popovers.</p> <p>The way around that is it to bind a pjax:end event so you can do stuff after the pjax content is inserted. In the popover example:</p> <pre><code>$(document) .on('pjax:end', function() { $('a').popover() }) </code></pre> <p>Whenever pjax content is loaded it will run that function and apply the popover functionality to any anchor elements, including newly inserted ones. You could further isolate it via a selector to just the container with the new content so you don't reapply functionality to things that haven't changed.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload