drupal 7 attach behaviors to ajax content
-
13-02-2021 - |
Pergunta
So... I load a node form via ajax into another page. I try to attach behaviors like this:
Drupal.attachBehaviors($('.ajax-form-container'));
The problem is that nothing happens. The form has no behaviors attached (autocomplete, collapsible fieldsets, draggable textarea etc)
Solução
ok, found the problem. you have to manually include the javascript files responsible for these behaviors on your page before the form is loaded via ajax:
"misc/vertical-tabs.js";
"misc/states.js";
"misc/form.js";
"misc/textarea.js";
"misc/collapse.js";
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow