trunk8
trunk8 copied to clipboard
trunk8 doesn't work with $.ajax
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.
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.
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.