First you have to transfer your expander code to a function:
function initExpander() { $('div.expandable').expander({ slicePoint: 200, preserveWords: true, widow: 4, expandText: 'continue reading', detailClass: 'expanderDetails', afterExpand: function(){ $('#mybutton').click();
Then you can use this function every time you need to initialize the expander, for example, after loading the DOM:
$(document).ready(function() { initExpander(); });
Or immediately after calling ajax:
$.ajax({ url: '/doajax',
If you use done () with ajax, this is good too:
$.ajax({ url: '/doajax',
Hope this helps;)
source share