Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
Cancelar el arrastre de un elemento ordenable

Un caso ordenable absolutamente común:

 <script> $(function() { $("#sortable").sortable(); }); </script> <ul id="sortable"> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul>

Problema. Es necesario cancelar el arrastre de un elemento en alguna condición y hay un buen consejo de Andrew Whitaker , pero ese enfoque funciona solo para jquery-ui-draggable y falla para clasificables:

 $("#sortable").sortable({ start: function() { return false; // will still cause `this.helper is null` } });

Será agradecido por las sugerencias.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Sortable tiene una capacidad de "cancelar" invocada usando sortable('cancel') .

De los documentos: "Cancela un cambio en la ordenación actual y lo revierte al estado anterior a cuando se inició la ordenación actual". Consulte http://api.jqueryui.com/sortable/#method-cancel .

Ejemplo de uso:

 $("#sortable").sortable({ stop: function(e, ui) { if ("I need to cancel this") { $(ui.sender).sortable('cancel'); } } });
over 4 years ago · Santiago Trujillo Report

0

Devolver false como sugiere fudgey funciona muy bien para hacer que las cosas no se puedan clasificar dinámicamente, pero también hay una opción de cancel en la configuración clasificable que le permite configurar también elementos no clasificables estáticos:

 $("#sortable").sortable({ // this prevents all buttons, form fields, and elemens // with the "unsortable" class from being dragged cancel: ":input, button, .unsortable" });
over 4 years ago · Santiago Trujillo Report

0

La devolución de llamada de la función de sort hace lo mismo para ordenar que arrastrar para arrastrar ( demostración ):

 $("#sortable").sortable({ sort: function() { if ($(this).hasClass("cancel")) { $(this).sortable("cancel"); } } });
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!