Search code examples
prestashopjquery-select2prestashop-1.7

Prestashop Select2 in admin backoffice


Prestashop: 1.7.6.2 I want use select2 in backoffice in Category but jQuery is not added and select2 not working. I use the hook:

error-message: jQuery.fn.select2.defaults.set is not a function

public function hookActionAdminControllerSetMedia()
{
    $this->context->controller->addJquery();
    $this->context->controller->addJQueryPlugin('select2');
    $this->context->controller->addJS(_PS_BO_ALL_THEMES_DIR_ . 'default/js/tree.js');
    $this->context->controller->addCSS($this->_path . 'views/css/' . $this->name . '.css', 'all');
}

Solution

  • The $this->context->controller->addJquery(); was removed in version 1.7.6.2

    so I use external select2 not from prestashop and its works.

    $this->context->controller->addJS(_PS_BO_ALL_THEMES_DIR_ . 'default/js/select2.min.js');