I have a form that uses ['#attached']['js']
to attach a simple javascript file. A checkbox element of this same form uses ['#ajax']
to dynamically update some portions of the form. I'm finding that, when the form is rebuilt after the ajax callback, the javascript file is reattached multiple times, causing unintended behaviors.
Is there any way to avoid reattaching a javascript file to a form if that same javascript has been attached previously?
once()
in the javascript file itself.