그냥 추가/삭제 된 항목의 ID를 어떻게 얻을 수 있습니까? 항목을 추가하거나 제거한 후 데이터베이스를 업데이트해야합니다.maggicsuggest 'selectionchange'추가/삭제 된 항목의 ID를 가져옵니다.
$(ms).on('selectionchange', function(event, combo, selection){
});
그냥 추가/삭제 된 항목의 ID를 어떻게 얻을 수 있습니까? 항목을 추가하거나 제거한 후 데이터베이스를 업데이트해야합니다.maggicsuggest 'selectionchange'추가/삭제 된 항목의 ID를 가져옵니다.
$(ms).on('selectionchange', function(event, combo, selection){
});
이벤트 매개 변수에서 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;
});
내가 할 것입니다 :
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);
});