Archive2

How to clear SearchManager results once processed with on('data')

Influencer

I have a modal dialog that pops up and shows a table of results. When I click OK on that, I do some processing on the results. as below, with the on('data') function.

However, that code seems to get triggered frequently and I don't understand why.

    var searchResults = detailSearch.data('results');
 ...
     searchResults.on('data', function() {
       var rows = searchResults.data().rows;
       for (var i = 0; i < rows.length; i++) {
 ...
       }
     });

That code is inside the button click handler, but the button click code is not executed repeatedly, only the above on('data') function code. The search is not rerun and in my close() code for the dialog, it calls search.finalize() to try to stop this happening, to no effect.

Any idea how I can reset the searchResults handler to prevent this?

0 Karma
Reply