Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trunk8 doesn't work with $.ajax #36

Open
ds-1010 opened this issue Aug 28, 2013 · 2 comments
Open

trunk8 doesn't work with $.ajax #36

ds-1010 opened this issue Aug 28, 2013 · 2 comments

Comments

@ds-1010
Copy link

ds-1010 commented Aug 28, 2013

Hi!
I have faced with strange problem.
If i use trunk8 in $.ajax call, for example

$.ajax({
      url: parameters.source,
      type: "POST",
      dataType: "json",
      async: false,
      data: ajaxData,
      success: function (data) {                    
          item = createItem(data);
          $('#some_id').append(item);
          item.find('.too-long').trunk8();
      }
});

nothing happens. Text not truncated.

But if i call for example

$(document).ready(function() {
    item = createItem( {Id :1, Name : "Test name"} );
    $('#some_id').append(item);
    item.find('.too-long').trunk8();
});

all works fine. Could you explain me such behavior.

Thank you in advance.

@ibigpapa
Copy link

ibigpapa commented Jan 6, 2014

var resultsPage = "http://10.14.191.153/snmp/bkgsearch2.php?query=";
var terms = '';
$(document).ready(function(){
$("#srcc").keyup(function(event){
if(event.keyCode == 13){
$("#srcbtn").click();
}
});
$('#menu').load('menu.html');
$('#srcbtn').click(function(){
terms = $('#srcc').val();
if(terms !== ''){
var loadPage = resultsPage.concat(terms);
$('#resultwrapper').load(loadPage,function(){
//$('#resultwrapper').removeHighlight();
//$('#resultwrapper').highlight(terms);
$('#trunk').trunk8({lines:2, fill: '… read more '});
$('#read-more').live('click',function (event){
$(this).parent().trunk8('revert').append(' read less');
return false;
});
$('#read-less').live('click',function (event){
$(this).parent().trunk8();
return false;
});
});
}
});
});

It appears i'm having the same issue as you. Execept it'll truncate the first elelment on my page.

@s1h4d0w
Copy link

s1h4d0w commented May 8, 2015

Hi dsys,

Are you sure there are no errors? It works for me if I call the Trunk8 function after the content is succesfully appended. This code works flawlessly for me:

function loadMore() {
    $.ajax({
        url: "loadmore.php",
        success: function(html){
            $(".content").append(html);
            $(".trunk8").trunk8();
        }
    });
    return false;
}

My content is in a span which sits in a table cell. The span has the trunk8 class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants