I would like to execute a JavaScript function only on node creation and node edit of one specific content type. It is only one small function call.
Let’s call the Drupal 7 content type “tear“, and the JavaScript function “doitnow();“
Any ideas how to do this?
Thank you very much.
Nils
You have to create your own module and implement hook_node_insert(), hook_node_update() and hook_node_view() and take the appropriate steps. You also have to create some JavaScript codes with Drupal behavior, and you’re ready. You have to use a temporary session variable after node creation/update, because this way you can check the existance of this variable in hook_node_view, and add the JS setting which “tells” a new “tear” content has been added.
You can download the whole module here.
You have to put this module to the
sites/all/modules/testModuledirectory.OK, here’s the code of the module:
testModule.info:testModule.module:js/testModule.behaviors.js:js/testModule.overlay.behaviors.js:Ask if something isn’t quite clear.