Topic: Material Input visually broken after setting value with JS
badmusician asked 5 years ago
Expected behavior
The input should look like this:
Actual behavior
The input looks like this: Label is above the text
Note: after clicking on the input, it updates and gets back to how it should look
Is there a method to manually redraw\update the visuals of the material input?
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Open
- User: Free
- Premium support: No
- Technology: MDB jQuery
- MDB Version: 4.18.0
- Device: PC
- Browser: Chrome
- OS: Windows 10
- Provided sample code: No
- Provided link: No
Grzegorz Bujański staff commented 5 years ago
Hi. Unfortunately, in Java Script, the val() method does not trigger any events - that's why the label does not rise up. You can call the event yourself using the trigger() method. I suggests something like
$('# my-input').val('new value').trigger('change')