Drupal behaviors

后端 未结 6 1936
南方客
南方客 2020-12-12 12:42
  • What are Drupal behaviors at all?
  • What type of service layer it offers to module developers?
  • What type of relation it maps to jQuery.ready
6条回答
  •  温柔的废话
    2020-12-12 13:31

    Along with answers mentioned above on of the key things is you can pass data from php to javascript which is as follows

    Passing values from PHP to Javascript with "Drupal.settings"

    You can easily make variables from PHP available to Javascript on the front end with Drupal.settings using drupal_add_js() function

     array('key' => 'value')), 'setting');
    ?>
    

    or

     'setting',
      'data' => array('myModule' => array('key' => 'value')),
    );
    ?>
    

    This will be available in Javascript as:

      if (Drupal.settings.myModule.key === 'value') {
        alert('Got it!');
      }
    

提交回复
热议问题