Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery call function only when object is created
    text
    copied!<p>I am using FitText <a href="https://github.com/davatron5000/FitText.js" rel="nofollow">https://github.com/davatron5000/FitText.js</a> to resize the text of some text I have in specific DIVs. The fact is that these DIVs are created into objects added to the page only when needed. But doing this way FitText won't get the DIV when page loads because in fact the DIV is not already there and so won't resize the text.</p> <p>Here is how I call FitText:</p> <pre><code>&lt;script type="text/javascript"&gt; jQuery(document).ready(function($) { jQuery(".cvd_right_master_item").fitText(2.8); }); &lt;/script&gt; </code></pre> <p>And here is the function that creates the DIV into an object:</p> <pre><code>function makeCvdBubble(params) { var cvdIndexId = params.cvdIndexId; var cvdTweetAuthor = params.cvdTweetAuthor; var cvdAuthorName = params.cvdAuthorName; var cvdTweetDescription = params.cvdTweetDescription; objectreference = document.createElement('div'); objectreference.setAttribute('id', 'indexId-'+cvdIndexId.toString()); $(objectreference).html('\ &lt;div class="cvd_right_master_item"&gt;\ &lt;div class="cvd_right_tweet_margin_float"&gt;\ &lt;img class="cvd_right_blue_bird" src="cross_video_day/images/cvd_blue_bird.png" /&gt;&lt;span class="cvd_right_tweet_username"&gt;@UserName&lt;/span&gt;\ &lt;span class="cvd_right_tweet_author"&gt;User Name&lt;/span&gt;\ &lt;span class="cvd_right_tweet_text"&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras ut posuere justo, eget consequat tortor. In sollicitudin condimentum arcu sed.&lt;/span&gt;\ &lt;/div&gt;\ &lt;div class="clear_both"&gt;&lt;/div&gt;\ &lt;span class="cvd_right_white_arrow"&gt;&lt;/span&gt;\ &lt;/div&gt;\ '); if (cvdTweetAuthor) $(objectreference).find('.cvd_right_tweet_username').html(cvdTweetAuthor); if (cvdAuthorName) $(objectreference).find('.cvd_right_tweet_author').html(cvdTweetAuthor); if (cvdTweetDescription) $(objectreference).find('.cvd_right_tweet_text').html(cvdTweetDescription); return (objectreference) //objectreference is the reference of the just created tweet } </code></pre> <p>Now how do I do to make FitText resizing the text when the object is created? Thank you!</p>
 

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