Select2 AllowClear event

why after click allow clear in my select2 if i can change the cssContainerclass, the select2 throw a Exception? Can i change the class of select2 after click allowClear?