I've inherited a badly programmed website. It happens to use jQuery v2.1.3 (against which I have no general complaints). On a page I've placed a select dropdown list. When a user changes the selection in this list, the page refreshes.
In Chrome developer tools, the change event listener turns out to be a line in the generic jQuery library that's loaded, from what I can see. The event handler is this:
if ( !(eventHandle = elemData.handle) ) {
eventHandle = elemData.handle = function( e ) {
// Discard the second event of a jQuery.event.trigger() and
// when an event is called after a page has unloaded
return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ?
jQuery.event.dispatch.apply( elem, arguments ) : undefined;
};
}
There is currently no JavaScript hooked up to this field (besides whatever's latching on to it by virtue of it merely being present in the page).
My question is how to prevent this from happening. I don't want pages to refresh whenever select lists happen to be changed, just because jQuery is loaded.
ETA: On the suggestion of @theAnubhav below, I've updated the outputted HTML to the below, but the page still refreshes on change:
<div class="field"><select id="field4860fb3b7d994e8d964fc71b24e32752">
<option value=""></option>
<option value="AF">Afghanistan</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AD">Andorra</option>
<option value="AO">Angola</option>
<option value="AR">Argentina</option>
<option value="AM">Armenia</option>
<option value="AU">Australia</option>
<option value="AT">Austria</option>
<option value="AZ">Azerbaijan</option>
<option value="BS">Bahamas</option>
<option value="BH">Bahrain</option>
<option value="BD">Bangladesh</option>
<option value="FR">France</option>
<option value="DE">Germany</option>
<option value="US">United States</option>
</select>
<script>$('#field4860fb3b7d994e8d964fc71b24e32752').on('change',function(e){ e.stopPropogation(); });</script>
</div>