Guest Posted June 11, 2020 Share Posted June 11, 2020 Some ideas ? Thank you I inserted my own javascript into the displayBackOfficeHeader, which is to show me the result of the selection in the selectbox in my module. public function hookDisplayBackOfficeHeader() { if (Tools::getValue('configure') == $this->name) { $this->context->controller->addJS(_PS_MODULE_DIR_.$this->name.'/js/my-custom.js'); } } renderForm: $fields_form[0] = array( 'form' => array( 'legend' => array( 'title' => 'custom test', 'icon' => 'icon-cogs', ), 'input' => array( array( 'type' => 'select', 'label' => $this->l('Select and custom values'), 'name' => 'custom_selection[]', 'id' => 'my-selection-values', 'required' => false, 'multiple' => true, 'col' => '6', 'desc' => '<span id="span-my-selected"></span>', 'options' => array( 'query' => $cb__ok, 'id' => 'id', 'name' => 'name', ) ), my-custom.js: $(document).change(function(){ var arr = $('#my-selection-values').val(); console.log(arr); document.getElementById('span-my-selected').innerHTML = arr; }) Link to comment Share on other sites More sharing options...
Verlonimo Posted June 11, 2020 Share Posted June 11, 2020 Hi, jQuery library is in Prestashop core.js which probably is loaded after your custom.js and that's why $ is not defined. So check on that. You should load your js after core.js.... Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now