Implementing HandlebarsJS with PHP and Yii to generate a page. Here is a snippet of the html/handlebars code on the page
{{#if embed_link}}
<p class='f_hidden_p'>
<a href='{{embed_link}}'>
{{embed_link}}
</a>
</p>
<div class = 'link-wrapper'>
<div class = 'link-container'>
<a class = 'link-anchor-box'>
<div class = 'link-pic-wrap'>
<div class='playable_wrap'>
<div class='play_btn'></div>
<div class = 'link-img'></div>
</div>
<div class = 'link-text-data'>
<div class = 'link-text-title'>
<span class = 'link-text-website'></span>
</div>
<div class = 'link-text-about'></div>
</div>
</div>
</a>
</div>
</div>
{{/if}}
The given code executes only when embed_link is true. In my scenario it is indeed true, and in this case I want to extract text from "f_hidden_p" using jQuery. This is what I have in my JS file:
$(document).ready(function(){
console.log($('.f_hidden_p').text());
console.log($('.f_hidden_p').val());
});
Sadly, this returns an empty string or undefined. Even though when inspecting the element, I can verify that the value of {{embed_link}} is not empty. I attempted assigning a unique id "embed_link" to the anchor tag like this:
$(document).ready(function(){
console.log($('#embed_link').text());
console.log($('#embed_link').val());
});
Yet, this approach also did not yield the desired result. I used identical syntax with other div elements within handlebars blocks and it worked flawlessly. However, it seems to be failing for this specific block for unknown reasons. NOTE: .f_hidden_p is hidden (display: none) through CSS. However, this should not obstruct .text() or .val() from retrieving the text.
Appreciate the assistance!