function MyModule_menu() {
$items['blah'] = array(
'title' = 'blah',
'page callback' => 'blah_page',
'type' => MENU_NORMAL_ITEM
);
$items['clickPath'] = array(
'title' => 'A title',
'page callback' => 'clickPath_page',
'type' => MENU_CALLBACK,
);
return $items;
}
function blah_page() {
$output = drupal_get_form(MyModule_form);
return $output;
}
function clickPath_page() {
return ('you clicked me!');
}
function MyModule_form($form,&$form_state) {
$output = '<div id="clickDiv">Click me</div>';
$form['blah'] = array(
'#type' => 'markup',
'#value' => $output,
'#ahah' => array(
'event' => 'click',
'path' => 'clickPath',
'wrapper' => 'clickDiv',
),
);
return $form;
}
Why won't the above work? Is it not possible to use ahah and events on form types of 'markup'? Do I have to use my own custom javascript?
You can stop reading here! I would like to end my sentences and question here, but stackoverflow is forcing me to input a minimum amount of characters. Apologies in advance!!!!
If you look at the Form API under "Special Elements" you can see that the #ahah
attribute is not supported for the markup
form type.
So I'm afraid you will have to roll your own JS in this case, or convert the markup
element into a normal form element (which it doesn't look like will work for your purposes).