What I have is fairly standard code for using JavaScript with SharePoint 2013. Inside the sharePointReady function, I have a few dynamic controls that are added to the page.
The problem is that when I attempt to call the click function, nothing is actually loaded on the page yet. It seems like a classic page lifecycle issue where I can't call a function on an element that is not part of the document yet.
I know that the .click code or selector is correct because after the page loads, inside the console...I am able to emulate a click.
Any posts that can help me out with this? Essentially, I'm asking the page 'hey did you load all my controls yet? good, now click'.
<script type="text/javascript">
$(document).ready(function () {
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function () {
sharePointReady();
});
$(".classnamehere").first().click();
});
</script>