How to get change event working of a taxonomy select box on a node form?

by Ahmad   Last Updated June 27, 2017 16:07 PM

I have a taxonomy, which I have added to a content type. Now a select box from the taxonomy appears when I want to create a node of that content type.

That content type have a cck field of type select.

In my module in the hook_form_alter I want to execute the js change event of the taxonomy select box, but it does not work. And when I try to execute the js change event on cck select box, it works fine.

here is my code.

function mymodule_form_alter(&$form, &$form_state, $form_id) {
     if($form_id == 'contenttype_node_form') {
           }) ;

", "inline");

Answers 1

This isn't really a Drupal question, but at a guess I'd say the problem is that you're binding the event to an element before the DOM has the element doesn't exist yet. You should use one of the standard jQuery methods to run your code when the document is ready, e.g.:

$(document).ready(function() {
June 21, 2012 09:19 AM

Related Questions

Drupal URL Arguments in Javascript

Updated May 01, 2015 21:03 PM

D7 Google Chart Render based on taxonomy selection

Updated October 06, 2017 21:07 PM

Allow only lowest taxonomy terms to assign to nodes

Updated April 22, 2015 01:03 AM