mouseevent - jQuery .trigger('click') inside interval function? -


this rephrased question here. after testing isolated problem, have no clue on fixing it. no need read previous question, simplified code:

the problem -> trigger('click') executes, event doesn't trigger when inside looped (intervaled) function

$(document.ready(function(){     var checkforconfirmation = function(){         clearinterval(checkinterval);         $("#anchorlink").trigger('click');     }     var checkinterval = setinterval(function(){checkforconfirmation()}, 5000); }); 

the function being called in intervals. when proper response replied, interval stops, , simulates click on anchor link.

in html file there anchor link <a id="anchorlink" href="#hiddendiv">show</a>.
points hidden div has content. i'm using fancybox plugin show hidden div when anchor link clicked.

if click on show link fancybox shows, expected.
if response back-end, code executes expected, fancybox not shown.
if move $("#anchorlink").trigger('click'); outside checkforconfirmation function, fancybox shows.
when replace $("#anchorlink").trigger('click'); $("#anchorlink").text('im clicked'); string shows in <a id="ancoredlink"> tag.

this summary, have tried in different situations.
problem in triggering click event while in looping function. $("#anchorlink") selector accessible, triggering correctly everywhere else. there problem in triggering mouse event inside looping function.

any suggestions?

try:

$(document).ready(function(){   // ... }); 

instead of:

$(document.ready(function(){   // ... }); 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -