1
선택 2 4.0.3을 단일 선택으로 사용 중입니다.select2에서 선택할 값을 검색 할 수 없습니다. 선택
변경 이벤트가 트리거되기 전에 값을 선택하려고합니다 (사용자가 선택하여 할당 할 값).
이 내가 이벤트 후크 사용하고 코드 내가 테스트 무엇 :
$('#mycombo').on("select2:selecting", function (evt) {
var $this = $(this);
console.log($this.val()); // This return the current value
console.log(evt.data); // This return unassigned
console.log(evt.params); // This return unassigned
console.log(evt.args); // This return unassigned
console.log(evt.object); // This return unassigned
})
나는 여기 Fire callback when selection was made with select2 4.0, and retrieve the value of last selection 예제를 시도하지만 선택과 같이 및 이벤트가 동시에 트리거 변경합니다.
나는 분실되어 도움이 될 것입니다. 당신은 PARAMS에 그 정보를이
$('#mycombo').on("select2:selecting", function (evt) {
console.log(evt.params.args.data); // this returns the object of
})
으로 예를 들면 시도하고 데이터에 당신이는 .text 또는 .ID 뭔가를 할 수 있으며이 옵션이나 텍스트를 가질 수
** ** evt.params **가 할당되지 않았습니다. – CrApHeR
여기에 작동 예제입니다 http://codepen.io/anon/pen/egmraE?editors=1010 – xploshioOn
답변을 수락 한 것으로 표시하고 코드를 다시 확인하겠습니다. 감사! – CrApHeR