Monday, June 3, 2024
126
rated 0 times [  130] [ 4]  / answers: 1 / hits: 14662  / 11 Years ago, thu, february 20, 2014, 12:00:00

I have a select element which is decorated by Select2 via the SonataAdminBundle.



I am trying to listen to the change event. The ID of my select tag is categorySelector.



This does not work:



var test = $('#categorySelector');

$(test).change(function() {

var theSelection = $(test).select2(val);
//$('#selectedID').text(theID);
console.log(theSelection);
});


How do I do this?


More From » jquery-select2

 Answers
4

I think this should work for you...



$('#categorySelector').on(change, function(e) {
var theSelection = e.val();
console.log(theSelection);
});

[#47560] Wednesday, February 19, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rohan

Total Points: 403
Total Questions: 93
Total Answers: 105

Location: Trinidad and Tobago
Member since Mon, Jul 13, 2020
4 Years ago
rohan questions
Tue, Sep 8, 20, 00:00, 4 Years ago
Fri, Aug 21, 20, 00:00, 4 Years ago
Mon, Aug 3, 20, 00:00, 4 Years ago
Thu, Jul 2, 20, 00:00, 4 Years ago
;