I have a decent understanding of jQuery and I'm in the process of developing a plugin. Specifically, it's a dropdown element that I'm working on.
Everything functions correctly when there's only one dropdown on the site. However, when there are multiple dropdown elements, the plugin fails to work.
This is the code snippet that activates the plugin:
$('#OfficeUI .dropdown').each(function(index, item) {
$(item).OfficeUIDropdown();
});
Below is the complete source code of the plugin:
$.fn.OfficeUIDropdown = function() {
var dropdownElement = $(this);
$.fn.selectedItem = '';
$(dropdownElement).addClass('no-select');
$(dropdownElement).append('<i class="fa fa-sort-desc"></i>');
$.fn.hasFocus = function() { return dropdownElement.hasClass('focus'); };
// Other plugin functions...
return this;
}
It's a lot of code, but I'm hopeful that someone can assist me. I'm open to any suggestions on how to enhance this plugin.
Here's a JsFiddle link to showcase the issue.
Clicking on the first dropdown's 'A' causes the second dropdown to open, which is puzzling to me.