
$(function() {
  $('body').on('change', '[js-validate-dedupe]', function(e) {
    $formEl = $(e.currentTarget);
    ValidationDeduper.updateFormState($formEl);
  });

  $('body').on('submit', '[js-validate-dedupe]', function(e) {
    var $form = $(e.target);
    ValidationDeduper.updateFormState($form);

    if (!ValidationDeduper.isValid($form)) {
      alert('There are duplicate book bags in this plan. Please fix them before proceeding.');
      e.stopPropagation();
      e.preventDefault();
    }
  });
});

$(document).on("page:update", function() {
  $('body').on('change', '[js-validate-dedupe]', function(e) {
    $formEl = $(e.currentTarget);
    ValidationDeduper.updateFormState($formEl);
  });

  $('body').on('submit', '[js-validate-dedupe]', function(e) {
    var $form = $(e.target);
    ValidationDeduper.updateFormState($form);

    if (!ValidationDeduper.isValid($form)) {
      alert('There are duplicate book bags in this plan. Please fix them before proceeding.');
      e.stopPropagation();
      e.preventDefault();
    }
  });
});

Fix bug where dedupe handler wasn't firing when the page changed (due to PJAX)