-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
[Bug]: Selects label dissapear #393
Comments
My code: |
Ok, im find the bug. If you initialize a < select > and initialize again < select > the label tag dissapear. |
I've also have seen this, and created a reinitialize function, which rebuilds the label and re-initializes the select element:
usage:
or
|
Can you give me a situation where you would want to initialize the same element twice? I think it is a mistake to initialize the element twice. I looked at the code behind the select elements and I think I see where the problem is if somebody does want to take to fixing this in the future. Because the original html label is changed and moved around when the select element is initialized, This could possibly be solved by checking if |
if you dynamically need to change the value of the select element, you will need to reinitialize the select element, otherwise the the change is not visible. |
I am currently working arround this by keeping a reference to the instance inside the costom web component in which the options are initialized. Whenever I need to interact with the Select thingy, I talk to the web component and implement a function in it. |
function redrawSelect(id) {
var instance = M.FormSelect.getInstance(document.querySelector(id));
var labeltext = instance.labelEl.textContent;
instance.destroy();
$(id).parent().append("<label for='" + id.replace("#", "") + "'>" + labeltext + "</label>")
M.FormSelect.init(document.querySelector(id));
} I'm using this lazy code to rebuilt a selector after repopulated it's options |
Before submitting...
Context
Label display not showing in SELECT element
Current Behavior
No response
Expected behavior
No response
Possible Solutions or Causes
my code:
Steps to reproduce
No response
Your Environment
The text was updated successfully, but these errors were encountered: