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

Rebuild only one field instead of entire page? #18

Closed schellenbergk closed 6 years ago

schellenbergk commented 6 years ago

It would be nice to target a specific element to rebuild floatLabels within instead of entire page (for optimization reasons). Is there a way to do that?

pryley commented 6 years ago

If using float-labels on multiple forms, why not initialise them independently? This will allow you to rebuild them independently of each other.

var floatlabels1 = new FloatLabels( '#form1' );
var floatlabels2 = new FloatLabels( '#form2' );
var floatlabels3 = new FloatLabels( '#form3' );

// do something

floatlabels2.rebuild();

Unless you want to be able to rebuild specific fields in a form. This would be trivial to implement, but I would need a good reason for adding such an extreme micro-optimisation to the codebase.