Drupal Module Development im using hook_form, How do I use Javascript -


i'm creating first module in drupal. have created .module file following function, hook_menu:

    $items['admin/config/module'] =      array(         'title' => 'module',         'description' => 'module management',         'page callback' => 'drupal_get_form',         'page arguments' => array('module_form'),         'access arguments' => array('administer module other applications'),         'weight' => 9999,         'file' => 'module.admin.inc',     ); return $items; 

javascript works in .module file

this code links file module.admin.inc form rendered, form rendered correctly. when want display data using ajax can't.

it seams drupal_add_js('path') not work.

how do this?

use #attached property on form add css or js form

to add css,

$form['#attached']['css'] = array( drupal_get_path('module', 'ajax_example') . '/ajax_example.css', ); 

to add js,

$form['#attached']['js'] = array( drupal_get_path('module', 'ajax_example') . '/ajax_example.js', ); 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -