Adding js to a drupal node form
- by googletorp
In Drupal you can create your own nodetype in a custom module. Doing this you get to create your own form which is all very nice.
However if you want to add js the form things get a bit more tricky. If you add the js in the form, the js will only be added form the form when it is loaded. If the user would post the form with validation errors, the form function is not run again and thus the js is not added. Normally you would just create a menu callback and add the js there, but for the node add form, this wont be a possible solution.
So what is the best solution for adding js in a node add form, to keep it persistant when the form doesn't validate?