vendredi 22 novembre 2019

CakePhp 3.8 with Jquery autocomplete not working

I'm trying to use the autocomplete jquery function to complete a field with one of two source values: ['pere', 'mele']. unfortunately it does not work.

default.ctp

     <script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
<script
src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">

    <!------ Include the above in your HEAD tag ---------->
    <?php echo $this->Html->script(['single']) ?>

in view file

<?php echo $this->Form->create($societa); ?>       

<fieldset>
     <h1>Aggiungi Società</h1>


    <div class="form-group">
        <div class="col-lg-10 col-lg-offset-2">
        <?php echo $this->Form->control('nome_societa',['class'=>'form-control','required' => true]);?>  
        </div>  
    </div>
    <div class="form-group">
        <div class="col-lg-10 col-lg-offset-2">
         <?php echo $this->Form->control('nome_societa_abbreviato',['class'=>'form-control','required' => true]);?>  
        </div>  
    </div>
    <div class="form-group">
        <div class="col-lg-10 col-lg-offset-2">
         <?php echo $this->Form->control('sede',['class'=>'form-control','id'=>'naruto','required' => true]);?>  
        </div>  
    </div>
    <div class="form-group">
        <div class="col-lg-10 col-lg-offset-2">
         <?php echo $this->Form->control('cap',['class'=>'form-control','required' => true]);?>  
        </div>  
    </div>    
    <div class="form-group">
        <div class="col-lg-10 col-lg-offset-2">
         <?php echo $this->Form->control('citta',['class'=>'form-control']);?>  
        </div>  
    </div> 
    <div class="form-group">
        <div class="col-lg-10 col-lg-offset-2">
         <?php echo $this->Form->control('pr',['class'=>'form-control']);?>  
        </div>  
    </div> 

    <div class="form-group">
        <div class="col-lg-10 col-lg-offset-2">
         <?php echo $this->Form->button(__('Salva'),['class'=>'btn btn-primary']);?>  
        </div>  
    </div>           
</fieldset> 
<?php echo $this->Form->end();?>  
<?php echo $this->Html->link('Indietro', ['action'=>'index'], ['class'=>'btn btn-primary']) ?>

in js file single.js

$(document).ready(function(){
    $("#naruto").autocomplete({
        source:['pere','mele']
    });    
});

in console google chrome

A cookie associated with a cross-site resource at http://bootstrapcdn.com/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.
add#:1 A cookie associated with a cross-site resource at http://forum.jquery.com/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.
add#:1 A cookie associated with a cross-site resource at https://forum.jquery.com/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.
add#:1 A cookie associated with a cross-site resource at http://jquery.com/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.

unfortunately the file does not work even if the console does not give errors

Aucun commentaire:

Enregistrer un commentaire