-
-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Select does not work without jQuery #43
Comments
I suspect without jquery, you should be using the alternative init code: document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('select');
var instances = M.FormSelect.init(elems);
}); |
Yes I have done it exactly like you described it. My workaround for now is to include jquery... |
Any updates on That? M.getClosestAncestor = function(el, condition) {
let ancestor = el.parentNode
while (ancestor !== null >>>>> && !$(ancestor).is(document) <<<< ) {
if (condition(ancestor)) {
return ancestor;
}
ancestor = ancestor.parentNode;
}
return null;
}; But when I comment the part out I still can not use the Library.... I wanted to implement a better Select with Ajax-Loading and IDs instead of names and search in Dropdown. |
OK I fixed the Bug!!! Since the Function is only used in Dropdown.js at a specific place, here is the Solution: /**
* Place dropdown
*/
_placeDropdown() {
// Container here will be closest ancestor with overflow: hidden
const getClosestAncestor = function(el, condition) {
let ancestor = el.parentNode;
while (ancestor !== null && !$(ancestor).is(document)) {
if (condition(ancestor)) {
return ancestor;
}
ancestor = ancestor.parentNode;
}
return null;
};
let closestOverflowParent = getClosestAncestor(this.dropdownEl, (ancestor) => {
return $(ancestor).css('overflow') !== 'visible';
}); Now it Works!!! :) How does a pull request work I also deleted the Function below, since it is never used... M.elementOrParentIsFixed = function(element) {
let $element = $(element);
let $checkElements = $element.add($element.parents());
let isFixed = false;
$checkElements.each(function() {
if ($(this).css('position') === 'fixed') {
isFixed = true;
return false;
}
});
return isFixed;
};``` |
…Query. Especially the function getClosestAncestor(). See issue materializecss#43
First: Thank you dudes! The compiliation process worked! Awesome... I see materialize is moving forward.
When I remove the jQuery dependency and there is a small issue when i am trying to expand a Select Component / DropDown Menu. The Error in the Console says:
Steps to Reproduce (for bugs)
Your Environment
The text was updated successfully, but these errors were encountered: