Issue when calling ajax "data-request" in version 3.0.56


htm page code:

    <div class="acceptance_checkbox">
      <input type="checkbox" name="acceptance" value="1" aria-invalid="false" checked="checked" class="acceptance">
      <a href="javascript:void(0)" class="accep" data-request="{{ __SELF__ }}::onAcceptance"
        {{ page_txt_acceptance }}

Handler code

function onAcceptance()
  // для загрузки файла из темы
  $theme =  Theme::getActiveTheme(); //use Cms\Classes\Theme;
  $title= file_get_contents($theme->getPath().'/partials/title_acceptance.htm');
  $txt= file_get_contents($theme->getPath().'/partials/txt_acceptance.htm');

  return [
      '#acceptance_modal' => $this->renderPartial('@acceptance', ['txt' => $txt, 'title' => $title, 'view_acceptance' => true])

This works in 3.0.50 and in 2.2.54

Hello. This is likely caused by the new Vanilla JS AJAX framework. It’s saying there is an issue within the btnOpenModal function, which is not shown here.

“modal is null”. Where is modal set?

function code btnOpenModal from file modal.js (modal.js in assets)

function btnOpenModal(idBtn, idModal)
  // console.log("from "+idBtn);
  // console.log("open "+idModal);

  let modal= document.querySelector("#"+idModal );
      modal.classList.add('open'); = 0 ;
  let scroll_bar = window.innerWidth - document.body.clientWidth + 'px'; = 'hidden'; = scroll_bar ;


Got it. Thanks for sharing the inner code.

This is a bug and it should be fixed from v3.0.58 onwards.

Keep an eye on the changelog for updates: Changelog - October CMS

Issue resolved in v3.0.59. Thank you.

1 Like