0

New to drupal 7, following code should work fine according to my knowledge can someone help me why ajax give me error in console ? and what the solution

Code

function user_activity_tree_structure_showoptional_form($form, &$form_state, $base_nid) {
      $form['enablecond'] = array(
        '#type' => 'checkbox',
        '#title' => "Checkbox  ",
        '#ajax' => array(
        'callback' => 'ajaxcall_func',
        'progress' => 'false',
      ),
    );
    return $form;
}


function ajaxcall_func(&$form, $form_state) 
{
    setcookie("checkbox_1",$form['enablecond']["#value"]);
    return null;
}

Console Error

js_Y5H_CdmZpIvEir8-B6htnqHb6_vJBznC3jPygHLV6dE.js:495 Uncaught TypeError: Cannot read property 'Drupal' of undefined
at Object.attach (js_Y5H_CdmZpIvEir8-B6htnqHb6_vJBznC3jPygHLV6dE.js:495)
at Object.<anonymous> (js_UYCsqqVg9hDgzN1bjf7T6Fy66IJRk810uQF1qy9Lgo4.js:61)
at Function.each (js_H_BqcoIBkzDSvN9rxK_RAvqVRCfKG3dcLloVRen-E84.js:4)
at Object.Drupal.attachBehaviors (js_UYCsqqVg9hDgzN1bjf7T6Fy66IJRk810uQF1qy9Lgo4.js:59)
at Drupal.ajax.success (js_Y5H_CdmZpIvEir8-B6htnqHb6_vJBznC3jPygHLV6dE.js:2127)
at Object.success (js_Y5H_CdmZpIvEir8-B6htnqHb6_vJBznC3jPygHLV6dE.js:1858)
at Object.c.success (js_Y5H_CdmZpIvEir8-B6htnqHb6_vJBznC3jPygHLV6dE.js:111)
at c (js_H_BqcoIBkzDSvN9rxK_RAvqVRCfKG3dcLloVRen-E84.js:4)
at Object.fireWith [as resolveWith] (js_H_BqcoIBkzDSvN9rxK_RAvqVRCfKG3dcLloVRen-E84.js:4)
at k (js_H_BqcoIBkzDSvN9rxK_RAvqVRCfKG3dcLloVRen-E84.js:6)
1
0

There was actually a conflict between Drupal 7 - contributed module -> navbar -> js -> displace.js with fancytree.js.

Just answering this question so that you should make sure that any third party library shouldn't conflict with core and contributed modules js libraries.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.