0

I am going to try more less text for my website. Here is my DEMO from codepen.io

So my website is SocialNetwork like Facebook. Some user was posting a long text I need less more text plugin because of this.

Now my website main page showing last 10 post and when users scroll down then user see show more post button. So if user click show more post then my jQuery more less plugin not working. What should I do for it anyone can help me ?

$(document).ready(function() {      
  $(".comment").shorten();      
  $(".comment-small").shorten({showChars: 50});    
 });

And this is my AJAX code for load more posts:

$('.more').die('click').live("click",function() {   
  var ID = $(this).attr("id");
  var P_ID = $(this).attr("rel");
  var URL=$.base_url+'post_more_ajax.php';
  var dataString = "lastid="+ ID+"&profile_id="+P_ID;
  if(ID) {
    $.ajax({
      type: "POST",
      url: URL,
      data: dataString, 
      cache: false,
      beforeSend: function() {
        $("#more"+ID).html('<img src="wall_icons/ajaxloader.gif" />'); 
      },
      success: function(html) {
        $("div#contentpostwallarea").append(html);
        $("#more"+ID).remove();
      }
    });
  } else {
    $("#more").html('The End');// no results
  }   
  return false;
});
Shiladitya
  • 11,650
  • 15
  • 23
  • 35
innovation
  • 2,093
  • 8
  • 34
  • 67

1 Answers1

0

I think you need to bind click dynamically you can see solution here In jQuery, how to attach events to dynamic html elements?

Community
  • 1
  • 1
Tornike
  • 1,245
  • 12
  • 35
  • Delegation is for events, not for plugins (even some plugins can implement some delegation option but that's up to plugin author) – A. Wolff Dec 21 '14 at 16:23
  • @KoKo you cann't bind any event until plugin not provided it or you cann't change its core code – Jain Dec 21 '14 at 16:28