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

378
Views
Posición del elemento de evento de 'cambio' clasificable de Jquery

¿Hay alguna forma de arrastrar la posición actual del ayudante sobre la nueva posición?

 $("#sortable").sortable({ start: function (event, ui) { var currPos1 = ui.item.index(); }, change: function (event, ui) { var currPos2 = ui.item.index(); } });

¡Parece que currPos1 y currPos2 tienen el mismo valor cuando ocurre un cambio real!

Lo que necesito lograr es resaltar para el usuario todas las posiciones entre 'iniciar elemento de arrastre' y 'elemento reemplazado actualmente'. Una vez que el usuario suelta el botón del mouse, se actualiza y solo entonces obtengo una nueva posición, pero la necesito antes de soltar el mouse.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

ACTUALIZADO: 26/08/2016 para usar la última versión de jquery y jquery ui más bootstrap para darle estilo.

  • demostración: http://so.lucafilosofi.com/jquery-sortable-change-event-element-position/
 $(function() { $('#sortable').sortable({ start: function(event, ui) { var start_pos = ui.item.index(); ui.item.data('start_pos', start_pos); }, change: function(event, ui) { var start_pos = ui.item.data('start_pos'); var index = ui.placeholder.index(); if (start_pos < index) { $('#sortable li:nth-child(' + index + ')').addClass('highlights'); } else { $('#sortable li:eq(' + (index + 1) + ')').addClass('highlights'); } }, update: function(event, ui) { $('#sortable li').removeClass('highlights'); } }); });
over 4 years ago · Santiago Trujillo Report

0

Esto funciona para mí:

 start: function(event, ui) { var start_pos = ui.item.index(); ui.item.data('start_pos', start_pos); }, update: function (event, ui) { var start_pos = ui.item.data('start_pos'); var end_pos = ui.item.index(); //$('#sortable li').removeClass('highlights'); }
over 4 years ago · Santiago Trujillo Report

0

Use update , stop y receive eventos, compruébelo aquí

¿El evento de actualización clasificable de Jquery solo se puede llamar una vez?

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!