I have a tabbed widget that shows three separate loops. Under the third tabbed section which is hidden by default, I show a search that gives ajax results. My problem is that I can't figure how to apply jScrollPane to the container div of the results. Everytime the search is entered, the container div is emptied and new results are appended so I need to reapply it each time. Here is the code I'm using to trigger the search.
jQuery( function( $ ) {
// search filed
var $s = $( '#s' );
// the search form
var $sForm = $s.closest( 'form' );
console.log( $sForm );
$sForm.on( 'submit', function( event) {
event.preventDefault();
$.post(
T5Ajax.ajaxurl,
{
action: T6Ajax.action,
search_term: $s.val()
},
function( response ) {
$("#music-results").empty();
$("#music-results").append( response );
},
);
});
});
Now I have the basic call to setup jscrollpane for the other loops but that doesn't get applied to the div in question because it is hidden by default I guess.
$(document).ready(function(){
$('#music-results').jScrollPane({showArrows: true,autoReinitialise: false});
});
So how can I apply jscroll to the div each time it's emptied and new results are added?