How do I trigger a Drupal-Function with Javascript/jQuery? -


i have checkbox different values. when user change checkbox trigger drupal-function field_attach_update http://api.drupal.org/api/drupal/modules!field!field.attach.inc/function/field_attach_update/7

i know how check checkbox-change jquery how can trigger drupal-function then?

you'll want check out form api ajax options. think you'll want define ajax['callback'] function calls field_attach_update.

<?php function my_form_func($form, $form_state) {   $my_checkbox_val = isset($form_state['values']['my_checkbox']) ? $form_state['values']['my_checkbox'] : null;   $form['my_checkbox'] = array(     '#type' => 'checkbox',     '#title' => t('check me'),     '#default_value' => $my_checkbox_val,     '#return_value' => $nid, // assuming working node, entity     '#ajax' => array(       'callback' => 'my_form_field_update_func',       'event' => 'click',     ),   );   return $form; }  function my_form_field_update_func($form, $form_state) {   if (isset($form_state['values']['my_checkbox'])) {     $node = node_load($form_state['values']['my_checkbox']);     field_attach_update('node', $node);   }   return $form['my_checkbox']; } ?> 

Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -