2012-05-07 53 views
1

你好朋友我正在做一個像模塊,並有一些困難運行它即ie。在所有其他瀏覽器中運行良好。概率是當我點擊按鈕沒有發生在ie中。任何人都可以看到我的代碼並幫助我。 IE是如此的痛苦。livequery不工作在ie

  $('.LikeThis').livequery("click",function(e){ 

     var getID = $(this).attr('id').replace('post_id',''); 
     var uid = $('.like_uid').val(); 
     var type_id = $('.like_type_id').val(); 


     $("#shlike-loader-"+getID).html('<img src="images/icons/like.gif" alt="" />'); 

    $.post("eg?postId="+getID+ '&uid=' + uid + '&type_id=' + type_id, { 


     }, function(response){ 
      $('#hiddenlikesval'+getID).remove(); 
      $('#likepanel'+getID).show(); 
      $('#likecontainer'+getID).append($(response).fadeIn('slow')); 
      var bing=$('#hiddenlikesval'+getID).val(); 
      $('#lplbl'+getID).html(bing); 
      $('#likePanel'+getID).css({'display':'block','width':'404px','padding':'5px 3px 5px 3px','background':'#ECEFF5'}); 
      $('#like-panel-'+getID).html('<input type="hidden" class="like_uid" id="like_uid'+getID+'" name="like_uid" value="'+uid+'"/><input type="hidden" class="like_type_id" id="like_type_id'+getID+'" name="like_type_id" value="'+type_id+'"/><div class="comtcontbtm unlwid"><a href="javascript: void(0)" id="post_id'+getID+'" class="Unlike liknlksh" title="Unlike"><span class="shareiconsbottom unlikeiconbtm"></span><span class="replyshare">unlike</span></a></div>'); 

      $("#shlike-loader-"+getID).html(''); 
     }); 
    }); 
+0

'livequery'已棄用。你應該使用'.live()'。 – SLaks

+1

@SLaks'live'已被棄用,您應該使用'on'或'delegate'(前1.7) – mattytommo

+1

從jQuery 1.7開始,不推薦使用.live()方法。使用.on()附加事件處理程序。 – Shikiryu

回答

1

你使用jQuery 1.7?如果是這樣,你應該使用onlivequery已棄用。如果你使用的是1.7以前的版本,你應該使用.delegate

1.7改變你的函數聲明:

$(document).on("click", ".LikeThis", function (e) { 
    //your stuff here 
}); 

對於預1.7將其更改爲:

$(document).delegate("click", ".LikeThis", function (e) { 
    //your stuff here 
}); 

在:http://api.jquery.com/on/

代表:http://api.jquery.com/delegate/

+0

你好thnaks的示例代碼我改變了我的整個代碼,但仍然存在prob。在它不工作 –

+0

嗯,你可以發佈你的問題在你的標記?是否有錯誤? – mattytommo

+0

消息:對象不支持此屬性或方法 行:1725 字符:5 代碼:0 –

0
$('.LikeThis').live('click', function (e) { 
      var getID = $(this).attr('id').replace('post_id', ''); 
      var uid = $('.like_uid').val(); 
      var type_id = $('.like_type_id').val(); 


      $("#shlike-loader-" + getID).html('<img src="images/icons/like.gif" alt="" />'); 

      $.post("modules/like/likeit.php?postId=" + getID + '&uid=' + uid + '&type_id=' + type_id, { 


      }, function (response) { 
       $('#hiddenlikesval' + getID).remove(); 
       $('#likepanel' + getID).show(); 
       $('#likecontainer' + getID).append($(response).fadeIn('slow')); 
       var bing = $('#hiddenlikesval' + getID).val(); 
       $('#lplbl' + getID).html(bing); 
       $('#likePanel' + getID).css({ 'display': 'block', 'width': '404px', 'padding': '5px 3px 5px 3px', 'background': '#ECEFF5' }); 
       $('#like-panel-' + getID).html('<input type="hidden" class="like_uid" id="like_uid' + getID + '" name="like_uid" value="' + uid + '"/><input type="hidden" class="like_type_id" id="like_type_id' + getID + '" name="like_type_id" value="' + type_id + '"/><div class="comtcontbtm unlwid"><a href="javascript: void(0)" id="post_id' + getID + '" class="Unlike liknlksh" title="Unlike"><span class="shareiconsbottom unlikeiconbtm"></span><span class="replyshare">unlike</span></a></div>'); 

       $("#shlike-loader-" + getID).html(''); 
      }); 
     }); 
+0

'live'已被棄用,你應該使用'on'或'delegate'(前1.7) – mattytommo

+0

任何人都可以幫助我一個「上」我從來沒有用過它 –