-1

I have created a sortable component with jQueryUI and this works fine including when these elements has created by appendTo jQuery function.

$template.appendTo("#lista_criterios");

$( "#lista_criterios" ).sortable({
    handle: ".criterio-header",
    placeholder: "alert alert-info",
    axis: 'y',
    update: showMessage('alert-success', 'Ordenacion de criterios completada.')
});

when a need twow an event when the sort is finished update and others functionalities of sortable element don't works.

Please can you help me?

Note: the example code is not identical of original.

Blacknet
  • 119
  • 1
  • 7

1 Answers1

0

If I understand your code correctly, the only problem I see in it is that the update option expects an event handler, not whatever showMessage() is returning if anything. Thus you either need to (1) wrap it in a function(){} call, or else (2) set its return value to one. As you say it's equivalent to alert, so the former is likely easier:

$( "#lista_criterios" ).sortable({
    // ...
    update: function(e, ui) {
        showMessage('alert-success', 'Ordenacion de criterios completada.');
    }
});

or the second way:

function showMessage(arguments) {
     return function(event, ui) {
          // show my alert with the arguments above
     };
}

Ref. documentation

blgt
  • 8,135
  • 1
  • 25
  • 28
  • @Blacknet `update` points to a value. Before, you were executing `showMessage()` and assigning its return value to `update`. With the above, you assign to it a new function (functions are valid values, in fact it's what `update` expects), which executes `showMessage()` – blgt Sep 10 '14 at 08:46
  • Thank you so much. Now i undestand perfectly. I have read the documentation but not explain hot you must use these events. Only when they execute. – Blacknet Sep 10 '14 at 09:24