@@ -496,7 +496,12 @@ FormElementDependenceController.prototype = {
496
496
}
497
497
return result ;
498
498
} ,
499
-
499
+ hideElem : function ( ele ) {
500
+ ele . hide ( ) ;
501
+ } ,
502
+ showElem : function ( ele ) {
503
+ ele . show ( ) ;
504
+ } ,
500
505
/**
501
506
* Define whether target element should be toggled and show/hide its row
502
507
*
@@ -507,8 +512,16 @@ FormElementDependenceController.prototype = {
507
512
*/
508
513
trackChange : function ( e , idTo , valuesFrom )
509
514
{
515
+ let upLevels = this . _config . levels_up ;
516
+ let ele ;
510
517
if ( ! $ ( idTo ) ) {
511
- return ;
518
+ idTo = 'row_' + idTo ;
519
+ ele = $ ( idTo ) ;
520
+ if ( ! ele ) {
521
+ return ;
522
+ }
523
+ } else {
524
+ ele = $ ( idTo ) . up ( upLevels ) ;
512
525
}
513
526
514
527
// define whether the target should show up
@@ -536,22 +549,22 @@ FormElementDependenceController.prototype = {
536
549
// toggle target row
537
550
if ( shouldShowUp ) {
538
551
var currentConfig = this . _config ;
539
- $ ( idTo ) . up ( this . _config . levels_up ) . select ( 'input' , 'select' , 'td' ) . each ( function ( item ) {
552
+ ele . select ( 'input' , 'select' , 'td' ) . each ( function ( item ) {
540
553
// don't touch hidden inputs (and Use Default inputs too), bc they may have custom logic
541
554
if ( ( ! item . type || item . type != 'hidden' ) && ! ( $ ( item . id + '_inherit' ) && $ ( item . id + '_inherit' ) . checked )
542
555
&& ! ( currentConfig . can_edit_price != undefined && ! currentConfig . can_edit_price ) ) {
543
556
item . disabled = false ;
544
557
}
545
558
} ) ;
546
- $ ( idTo ) . up ( this . _config . levels_up ) . show ( ) ;
559
+ this . showElem ( ele ) ;
547
560
} else {
548
- $ ( idTo ) . up ( this . _config . levels_up ) . select ( 'input' , 'select' , 'td' ) . each ( function ( item ) {
561
+ ele . select ( 'input' , 'select' , 'td' , 'div ') . each ( function ( item ) {
549
562
// don't touch hidden inputs (and Use Default inputs too), bc they may have custom logic
550
563
if ( ( ! item . type || item . type != 'hidden' ) && ! ( $ ( item . id + '_inherit' ) && $ ( item . id + '_inherit' ) . checked ) ) {
551
564
item . disabled = true ;
552
565
}
553
566
} ) ;
554
- $ ( idTo ) . up ( this . _config . levels_up ) . hide ( ) ;
567
+ this . hideElem ( ele ) ;
555
568
}
556
569
}
557
570
} ;
0 commit comments