You are here

function ctools_ajax_text_button in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 includes/ajax.inc \ctools_ajax_text_button()

Render text as a link. This will automatically apply an AJAX class to the link and add the appropriate javascript to make this happen.

Note: 'html' => true so be sure any text is vetted! Chances are these kinds of buttons will not use user input so this is a very minor concern.

Parameters

$text: The text that will be displayed as the link.

$dest: The destination of the link.

$alt: The alt text of the link.

$class: Any class to apply to the link. @todo this should be a options array.

$type: A type to use, in case a different behavior should be attached. Defaults to ctools-use-ajax.

5 calls to ctools_ajax_text_button()
ctools_ajax_image_button in includes/ajax.inc
Render an image as a button link. This will automatically apply an AJAX class to the link and add the appropriate javascript to make this happen.
ctools_ajax_sample_login in ctools_ajax_sample/ctools_ajax_sample.module
A modal login callback.
ctools_ajax_sample_page in ctools_ajax_sample/ctools_ajax_sample.module
Page callback to display links and render a container for AJAX stuff.
ctools_modal_image_button in includes/modal.inc
Render an image as a button link. This will automatically apply an AJAX class to the link and add the appropriate javascript to make this happen.
ctools_modal_text_button in includes/modal.inc
Render text as a link. This will automatically apply an AJAX class to the link and add the appropriate javascript to make this happen.

File

includes/ajax.inc, line 51
Set this so we can tell that the file has been included at some point.

Code

function ctools_ajax_text_button($text, $dest, $alt, $class = '', $type = 'use-ajax') {
  drupal_add_library('system', 'drupal.ajax');
  return l($text, $dest, array(
    'html' => TRUE,
    'attributes' => array(
      'class' => array(
        $type,
        $class,
      ),
      'title' => $alt,
    ),
  ));
}