Javascript wont work on elements generated with this plugin
-
Hi
i have installed plugin and it works fine, i places my repeater template and im getting output that i need, only issue i have is that jquery functions wont work when this plugin generates markup.
It just simple addClass and slideToggle, but its not working.
Here is my repeater code:
<div class="row success"> <div class="col-sm-4 no-pad-r img-toggle"> <?php the_post_thumbnail(); ?> </div> <div class="col-sm-6 col-sm-offset-1 no-pad-l"> <h4 class="heading-toggle"><?php the_title(); ?></h4> <div class="line"></div> <p class="intro">"<?php the_field('first_line'); ?>."</p> <div class="toggle-content" style="display: none"> <div class="main-copy"> <?php the_content(); ?></div> <h5><?php the_field('author_name'); ?></h5> <p class="position"><?php the_field('author_position'); ?></p> </div> <button class="btn toggle btn-danger"></button> </div> </div>And here is my javascript, im loading it from external file, and everything works when i manually add elements with my query for custom posts, but when using shortcode it wont work.
$(document).ready(function() { $( ".toggle" ).click(function() { $(this).prev( ".toggle-content" ).slideToggle(); $(this).closest( ".success" ).toggleClass( "highlight" ); $(this).toggleClass( "open" ); }); });There is no errors in console.
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
The topic ‘Javascript wont work on elements generated with this plugin’ is closed to new replies.