djibe / material

Material Design 2 for Bootstrap 4 (active fork of Daemonite Material)
https://djibe.github.io/material/
MIT License
68 stars 11 forks source link

How do I call change() on TextField? #19

Closed Devnsyde closed 3 years ago

Devnsyde commented 3 years ago

I have tried so many variations and they are all undefined:

$('#inputState').MaterialTextField
$('#inputState').MaterialDesignTextfield
$('#inputState').MDTextfield
$('#inputState').mdTextfield
$('#inputState').mdTextField
$('#inputState').MDCTextField
$('#inputState').mdcTextField

I need to call change() because I have put information into the field programmatically and I need the floating label to move up.

djibe commented 3 years ago

Hi, Material for Bootstrap has nothing to do with Material Design Components you are declaring.

For calling change() on textfield with floating label, read this: https://djibe.github.io/material/docs/4.5/material/text-fields/#usage

Tell me if you have more questions.

Devnsyde commented 3 years ago

They're not the same at all? Wow I feel dumb lol.. I fixed it by doing the following:

$timeout(function () {
                        $('#inputCity, #inputState, #inputCountry').closest(".floating-label").addClass("has-value");
                    }, 100);

I had to use a timeout because the input isn't set right away I guess, I am also hoping for a better way..

djibe commented 3 years ago

Hi, I'll try to look into it.

djibe commented 3 years ago

Hi @Devnsyde ,

did you try this ?

$('#inputCity, #inputState, #inputCountry').on('change', function(){
  $('.floating-label .custom-select, .floating-label .form-control').floatinglabel();  
})
djibe commented 3 years ago

Hi @Devnsyde, feel free to reopen Issue to chat more if necessary