pryley / float-labels.js

A zero-dependency plugin that applies the float label pattern to a form.
https://pryley.github.io/float-labels.js/
MIT License
88 stars 22 forks source link

get attribute value in modal dialog #31

Closed wagnerfillio closed 5 years ago

wagnerfillio commented 5 years ago

I have searched, and found something close to my problem, but it did not solve # 14.

Using a Modal Dialog, I was unsuccessful in displaying the field label.

As the field was populated via an ajax (json) return. its value attribute is always empty.

How can I check this case and display the label correctly for modal dialog?

lbl

pryley commented 5 years ago

Have you tried triggering a rebuild after the ajax return and a value is added?

i.e. floatlabels.rebuild()

Please see the usage section in the readme.

wagnerfillio commented 5 years ago

Here's how I did it. I declared the variable:

var floatlabels;

Inside the ready event I wrote the function:

floatlabels = new FloatLabels( 'frm-receita', { style: 1, });

and after the successful ajax response, I added: floatlabels.rebuild();

But it still does not work!!

pryley commented 5 years ago

send me a link

wagnerfillio commented 5 years ago

Hello, playing a page to put the example, I found out where the problem was, do not just add floatlabels.rebuild () in the ajax return. In my case, it was necessary to add after the objeto_form();

success: (function (objeto) { objeto_aviso = objeto; objeto_form(); floatlabels.rebuild(); ret = true; }),

pryley commented 5 years ago

Please close the issue if it is solved.

wagnerfillio commented 5 years ago

thank you