Skip to content

Instantly share code, notes, and snippets.

@firebelly
Created May 13, 2011 15:17
Show Gist options
  • Save firebelly/970719 to your computer and use it in GitHub Desktop.
Save firebelly/970719 to your computer and use it in GitHub Desktop.
jquery bug in IE for selecting field set to display
$('#exhibitor_exhibitor_registration_level_id').bind('change', function(){
var selected_index = $(this).get(0).selectedIndex;
var type = $(this).get(0).options[selected_index].text.split(':')[0].toLowerCase().trim();
var type_name = type.match(/school/) ? "school" : "business";
$(".entity_name").hide();
$("." + type_name).show();
});
@firebelly
Copy link
Author

and the fix is (mostly because IE does not implement trim() for some inexplicable reason):
$('#exhibitor_exhibitor_registration_level_id').bind('change', function(){
var selected_index = $(this)[0].selectedIndex;
var type = $($(this)[0].options[selected_index]).text();
type = $.trim(type.split(':')[0].toLowerCase());
var type_name = /school/.test(type) ? "school" : "business";
$(".entity_name").hide();
$("." + type_name).show();
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment