简体   繁体   中英

How do I trigger fitVids for multiple, dynamically generated ids on a page?

I'm working on a responsive tumblr-theme based on the 1140GRID. To make the static videos fit the column, I used the jquery fitvids plugin. My setup code looks like this:

  $(document).ready(function(){
    $("#post_{PostID}").fitVids();
  });

and the accompanying html like this:

<div class="container">
  <div class="row">
    <div class="ninecol"> //grid I want it to fit into
      {Block:Video}     
        <div id="post_{PostID}">
          {Video-500}
        </div>
      {/Block:Video}
    </div>
  </div>
</div>            

How do I trigger fitVids for multiple, dynamically generated ids on a page?

Thank you!

You may want to put that closing DIV inside the video block.

<div class="container">
  <div class="row">
    <div class="ninecol"> //grid I want it to fit into
      {Block:Video}     
      <div id="post_{PostID}">
        {Video-500}
      </div>
      {/Block:Video}
    </div>
  </div>
</div>

Then, you could target all the subdivs of ninecol.

<script>
$(document).ready(function(){
  $('.ninecol > div').fitVids();
});
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM