locked
function in if statement RRS feed

  • Question

  • User-1826049516 posted

    Hi,

    Where I am using .modal:visible I would like to exclude one particular one (has data-view=create). I know I can use .not() but I'd have to use it twice:

    if( ( $( ".modal:visible" ).not( "[data-view='CREATE']" ).find( "div > input" ).prop( "disabled" ) === true && !$( e.target ).parents().is( ".modal-controls, .modal-menu" ) ) || !$( e.target ).parents().is( ".modal" ) ) {
    
    	$( ".modal:visible" ).not( "[data-view='CREATE']" ).find( "div > input:enabled" ).prop( "disabled", true ).end().find( ".modal-menu" ).fadeOut( function() {
    	
    		$( this ).find( "a[data-control='modal']" ).show().end().find( "a[data-control='edit']" ).hide();
    		
    	} );
    	
    }
    

    Can I pass the first call to .modal:visible to the 2nd call as $( this ) in any way, or something else that doesn't require two .not()?

    Thanks

    Wednesday, January 23, 2019 7:03 PM

Answers

  • User1724605321 posted

    Hi ldoodle ,

    You can try something like :

    var item = $( ".modal:visible" ).not( "[data-view='CREATE']" );
    
    if( ( item.find( "div > input" ).prop( "disabled" ) === true && !$( e.target ).parents().is( ".modal-controls, .modal-menu" ) ) || !$( e.target ).parents().is( ".modal" ) ) {
    
    	item.find( "div > input:enabled" ).prop( "disabled", true ).end().find( ".modal-menu" ).fadeOut( function() {
    	
    		$( this ).find( "a[data-control='modal']" ).show().end().find( "a[data-control='edit']" ).hide();
    		
    	} );
    	
    }

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 24, 2019 2:56 AM