drupal 7 - JQuery class check on mouseup -


i have following code works when detecting mousedown , mouseup. problem begins within mouseup trying check if target element has class.

the code within if-statement never executes.

$(this).find('td:first a.tabledrag-handle').mousedown(     function(){          $(this).mouseup(             function(){                 console.log('mouseup detected');                  $(this).parents('tr').css('background', 'red');                  if( $(this).parents('tr').hasclass('drag-previous') ){                     console.log('dragged');                     $(this).parents('tr').css('background', 'blue');                 }             }         );     } ); 

the if( $(this).parents('tr').hasclass('drag-previous') ) ... code never executes.

can suggest better technique or work around solve problem, please?

update:

what i'm trying achieve detecting drag-&-drop events on following table. need read weight each row generated dragging , set figure in 'custom weight' field , save custom weight.

enter image description here

that needs take place each individual row , that's why detecting mousedown , mouseup on crosshairs instead on mousein or out on row, example.

use mouseenter , mouseleave event

window.jquery('table tr').find('td:first a.tabledrag-handle').mouseenter(function () {     window.jquery(this).parents('tr').css('background', 'red'); });   window.jquery('table tr').find('td:first a.tabledrag-handle').mouseleave(function () {     if (window.jquery(this).parents('tr').hasclass('drag-previous')) {         console.log('dragged');         window.jquery(this).parents('tr').css('background', 'blue');     } }); 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

angularjs - ng-repeat duplicating items after page reload -