First sorry if its a stupid question but i ran into a problem what i cant really solve.
I am loading a html file with the load function, and my problem is if i load the html file with the load function, the selectors with jquery dont really work, only with css.
(i use codeigniter)
example
load the html
$('.get_posts').hide().load('stream/load_posts').fadeIn(800);
so this html (view) file contains the following
<?php if(isset($stream_posts)): ?>
<?php foreach($stream_posts as $sp): ?>
<div id="sp_<?php echo $sp->sid; ?>" class="row stream-posts">
<div class="span1 stream-thumb">
<ul class="stream-thumbnails unstyled">
<li>
<a href="#" class="stream-thumbnail">
<img src="http://placehold.it/60x60" alt="">
</a>
</li>
</ul>
</div>
<div class="span5 stream-content">
<a href="#" class="author"><?php echo $sp->first_name ." ". $sp->last_name; ?></a>
<p id="stream-text">
<?php echo nl2br(auto_link($sp->text)); ?>
</p>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
i use codeigniter so at this line <?php echo nl2br(auto_link($sp->text)); ?> Automatically turns URLs and email addresses contained in a string into links, so when i have an auto link i would like to add an oembed class to it, so i tried the following
$("p.stream-content a").addClass('oembed');
and its not working, tried with css with the same selector with difference by coloring the anchor tags red, in css it works, than i discovered, the jquery selector part its not working because i use load, if i uncomment load and show the results via php it adds the class fine with jquery too.
Could please someone give me a hint for this?
Thank you
Did you try adding the class on the callback of
load()?Note that I have changed your
$('p.stream-content...because there is no<p>element withclass="stream-content"