Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery Sortable Events Not Firing

I'm sorry if this is super simple but I just cannot see what is wrong but the update event (or any event I have tried) is not firing in sortable. I tried to create a simple test using just the basic example they provide but it still fails. Can anyone help?

HTML:

<ol class='example'>
  <li>First</li>
  <li>Second</li>
  <li>Third</li>
</ol>

My main.js

$(document).ready(function() {
$("ol.example").sortable({
    update:function(event, ui){
        alert("in the update");
    }
});

})

The closest open issue I found was Why is sort the only event firing for jQuery UI .sortable()?. But that still isn't the helping. I have also tried using binding for the event which also failed. I am using jquery version 1.9.1 in case that matters.

like image 266
user1035760 Avatar asked Dec 04 '25 04:12

user1035760


1 Answers

I think you've a problem in the include of the jQuery librairies, please try to Replace :

<script type="text/javascript" src="jslib/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="jslib/jquery-ui.min.js"></script> 
<script type="text/javascript" src="jslib/jquery-sortable.js"></script> 

By :

<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>

If it work so verify the librairies inside jslib folder.

Full working code :

<!DOCTYPE html>
<html>
    <head>
         <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
         <script type="text/javascript" src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
    <head>

    <body>

        <ol class='example'>
          <li>First</li>
          <li>Second</li>
          <li>Third</li>
        </ol>

        <script>
            $(document).ready(function() {
                $("ol.example").sortable({
                    update:function(event, ui){
                        alert("in the update");
                    }
                });
            });
        </script>

    </body>

</html>
like image 102
Zakaria Acharki Avatar answered Dec 06 '25 16:12

Zakaria Acharki