ajax pager working depends on if js file is loaded in module .info file
It is the Drupal behavior JS code copied form your blog post.

(function ($) {
  Drupal.behaviors.addCtoolsModalClass = {
    attach: function (context) {
        $('#modalContent .pagination ul li a').addClass('ctools-use-modal');
        $('#modalContent .pagination ul li a').addClass('ctools-modal-imgsearch-modal-style');
    }
  }
})(jQuery);


The most meaningful thing I can find here is the class name ctools-use-modal. Obviously, this class name is used for ctools module. So I search this class name and find below snippet from js/modal.js in ctools module (version 7.x-1.9).

  Drupal.behaviors.ZZCToolsModal = {
    attach: function(context) {

      $('area.ctools-use-modal, a.ctools-use-modal', context).once('ctools-use-modal', function() {
        var $this = $(this);
        $this.click(Drupal.CTools.Modal.clickAjaxLink);


Now we have the full picture.

In your JavaScript code, you want to add a class name which is required for Ctools JavaScript code. AJAX does not work because the Ctools JavaScript code is run before adding the class name, so Drupal.CTools.Modal.clickAjaxLink never bind to the link.

Yu can fix it by manually run the attach behavior again after adding classname.

Solution

(function ($) {
  Drupal.behaviors.addCtoolsModalClass = {
    attach: function (context) {
        $('#modalContent .pagination ul li a', context)
          .addClass('ctools-use-modal')
          .addClass('ctools-modal-imgsearch-modal-style');

        Drupal.behaviors.ZZCToolsModal.attach(context);
    }
  }
})(jQuery);


Note: since all the code inside Drupal.behaviors.addCtoolsModalClass is wrapped with jQuery.fn.once, which means every code inside is only be implemented once if the selector finds the element. So you don't need to worry about binding the same event twice.