I'm trying to clear all inputs from a page, but I need to know if the input been cleared is a select2 input, so I can do something like this:
$(this).val('');
$(this).select2('destroy').select2(select2_options);
Thanks,
$('#s2id_' + $(this).attr('id')).length > 0
The jQuery datepicker library adds a 'hasDatepicker' class to the input when it is applied, and removes the class when the widget is destroyed. It would be convenient if Select2 could do the same thing with a 'hasSelect2' class.