html - Jquery Click Event Not Firing On First Click, but does on second click, why? -


i've got jquery code,

$("a.reply").click(function() { //code }); 

when click link .reply class first time, nothing happens. second time click, code inside click function works.

the link being inserted on page using php mysql database. it's not being inserted dynamically.

why happening? solution?

the badass code:

$(function(){ //textarea max width var textmaxwidth = $('#wrapper').css('width'); //initialize focus ids different var oldcommentid = -1; var newcommentid = -2; //end of initialization  $("a.reply").click(function() {         newcommentid = $(this).attr('id');         if (newcommentid == oldcommentid)         {         oldcommentid=newcommentid;         $("#comment_body").focus();         }         else         {         $('#comment_form').fadeout(0, function(){$(this).remove()});         var commetformcode = $('<form id="comment_form" action="post_comment.php" method="post"><textarea name="comment_body" id="comment_body" class="added_comment_body" rows="2"></textarea> <input type="hidden" name="parent_id" id="parent_id" value="0"/> <div id="submit_button"> <input type="submit" value="share"/><input type="button" id="cancelbutton" value="cancel"/></div></form>');         commetformcode.hide().insertafter($(this)).fadein(300);         //         var id = $(this).attr("id");         $("#parent_id").attr("value", id);         oldcommentid=newcommentid;         //dynamicformcreation function         dynarun();         //         }            return false;     });          dynarun();          function dynarun()         {         //form re-run functions         $('#comment_body').elastic();         texthover();         $("#comment_form input, select, button").uniform();         textareasizer();         $("#comment_body").focus();         $("abbr.timestamp").timeago();         return false;         }          //textarea resizer function         function textareasizer(){$("#comment_body").css('max-width', textmaxwidth);return false;}          //other miscellaneous functions         $('.comment-holder').hover(         function(event) {             $(this).addclass('highlight');         },         function(event) {             $('.comment-holder').removeclass('highlight');         }         );          function texthover()         {         $('.added_comment_body').hover(             function(event) {                 $(this).parent().parent().addclass('highlight');             },             function(event) {                 $('.comment-holder').removeclass('highlight');             }         );         return false;         } }); 

this longshot, running sort of tracking script? webtrends or coremetrics (or of own script, that's globally looking clicks)? ran similar problem while ago, initial-click being captured coremetrics. thought.


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? -