Jump to content

[PS 1.7.6.5] ReferenceError: $ is not defined


Guest

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...