I have a form with a couple of selects inside. I'm applying the select2 jquery plugin over those selects like this:
$("select.company_select, select.positions_select").select2();
The select's work fine, but I have this code to autosubmit my form (I have the autosubmit class on the form tag).
var currentData;
$('.autosubmit input, .autosubmit select, .autosubmit textarea').live('focus', function () {
currentData = $(this).val();
});
$('.autosubmit input, .autosubmit select, .autosubmit textarea').live('change', function () {
console.log('autosubmiting...');
var $this = $(this);
if (!currentData || currentData != $this.val()) {
$($this.get(0).form).ajaxSubmit(function (response, status, xhr, $form) {
currentData = "";
});
}
});
The thing is that with the select2, the change or the focus event doesn't fire at all. If I remove the select2, then the events get fired perfectly.
What am I doing wrong?