Forum Discussion

vaishnavi's avatar
vaishnavi
Expert
10 years ago

Fire javascript/jquery event after search is completed

Hi,

I have 'search-encapsulation' on a page. Whe I go to 'SearchPage', search result is displayed with pagination.

 

I want to do :-

1. capture when the rearch results are loaded

2. DOM manipulation of the search result DOM

 

My assumption is, search results are getting loaded through an AJAX request.

Thus I am trying to capture/use GLOBAL ajaxComplete event as below :-

 

    $(document).ajaxComplete(function(event,request, settings) {
        console.log('ajaxComplete handler start');
        console.log(event);
        console.log(request);
        console.log(settings);
        console.log('ajaxComplete handler end');
    });

 

I have added above handler in skin wrapper 'Page Head Bottom Content' section.

'ajaxComplete' event is getting triggered on page refresh.

But when I click on pagination links to load next search results, 'ajaxComplete' event is not getting triggered.

 

Can anyone help me in this?

 

Thanks,

Vaishnavi

 

  • Try putting that $.ajaxComplete JS block into a custom component exactly named "last_chance_html". This will be inserted AFTER the native Lithium JavaScript stuff.

    Which probably is the reason you cannot catch the AJAX requests made by Lithium Code, your code is inserted BEFORE and therefore executed BEFORE the native Lithium JS code, so your event "catcher" doesn't listen to events registered later on in the code...