2014-07-09 3 views

답변

0

이벤트 매개 변수에서 diff를 가져올 수 없습니다.

당신이 할 수있는 일 :

1 : 기능 요청을 열 수 있도록 오픈 소스 프로젝트입니다. 더 나은 방법은 직접 구현하고 끌어 오기 요청을 생성하는 것입니다.

$(ms).on('selectionchange', function(event, combo, selection, diff){ 
    // diff is an array of json objects that were added/removed  
}); 

: 2 : 그것은이 같은해야 당신은 현재 선택을 추적 할 수 있습니다 후 수동으로 수행 자신은 diff :

여기
$(ms).on('selectionchange', function(event, combo, selection, diff){ 
    if(this.cursel){ 
     // check diff b/w selection and this.cursel 
    } 
    this.cursel = selection; 
}); 
0

내가 할 것입니다 :

var diffArray = []; 
 

 
$(ms).on('selectionchange', function(e, m, records) { 
 

 
    var l = records.length; 
 
    var a1 = a2 = []; 
 
    var action = "add"; 
 

 
    if (l > diffArray.length) { 
 
    a1 = records; 
 
    a2 = diffArray; 
 

 
    } else { 
 
    a1 = diffArray; 
 
    a2 = records; 
 
    var action = "remove"; 
 
    } 
 

 
    var difference = $.grep(a1, function(el) { 
 
    return $.inArray(el, a2) == -1; 
 
    }); 
 
    
 
    diffArray = records.slice(); 
 
    
 
    console.log(action); 
 
    console.log(difference); 
 
    
 

 
});

관련 문제