2012-10-01 3 views
1

if (delete_box 클릭) else if (현재 비어 있음)에서 어떻게 할 수 있습니까? 그들은 둘 다 (남자와 delete_box) 같은 목적을 가지고 있지만 하나 또는 다른 누른 다음 약간 뭔가 다른 일이 클릭하면.jQuery else if with Ajax

$(man).add(delete_box).click(function(){ 
     if(App.manager != true){ 
      overlay.fadeIn('fast',function(){ 
       box_2.animate({'top':'200px'},500); 

        $('#manager_pass').submit(function(evt){ 

         evt.preventDefault(); 

         data = { 
          managerPassword: $('#token').attr('value'), 
          action: 'passwordManager' 
         }; 

         App.manager = $('#token').attr('value'); // set the manager token to the one inserted so that it's stored inside the page 

          $.ajax({ 
           url: App.URL_manager, 
           data : data, 
           dataType: 'json', 
           type: 'POST', 
           success: function(r){ 
            if (r.success) { 
              box_2.animate({'top':'-250px'},500,function(){ 
              overlay.fadeOut('fast'); 
              }); 

              $('.action_wrapper').fadeOut(1000,function(){ 
                $('.add_staff').fadeIn(1000); 
              }) 
            } 

            else { 
              $('#manager_pass').fadeOut(1000,function(){ 
               $('.error').fadeIn(1000); 
              }) 
             } 
           } 

          }); 

        }); 


       }); 
     } 

     else if() 

     else{ 
      action_wrapper.fadeOut(1000, function(){ 
       $('#add_staff').fadeIn(1000); 

      }) 
     } 


}); 

답변

1

is 메서드를 사용할 수 있습니다.

$(man).add(delete_box).click(function(event){ 
    // ... 
    else if ($(event.target).is(delete_box)) { 
     // ... 
    } 
}) 

http://jsfiddle.net/9gcdQ/