By najubudeen on
i want to add a javascript function into a div tag of ctool modal popup. i have written my codes below. it doesn't work.
function ajax_popup_call_menu() {
$items = array();
$items['tested'] = array(
'title' => 'ajax popup call Test',
'page callback' => 'ajax_popup_call_test_main',
'access arguments' => array('access content'),
);
$items['tested/%ctools_js/gone'] = array(
'page callback' => 'ajax_popup_call_test_modal_callback',
'page arguments' => array(1),
'access arguments' => array('access content'),
);
return $items;
}
function ajax_popup_call_test_main() {
ctools_include('ajax');
drupal_add_js(drupal_get_path('module','ajax_popup_call').'/jspage.js');
ctools_include('modal');
ctools_modal_add_js();
$output = l('Load modal content', 'tested/nojs/gone', array(
'attributes' => array('class' => 'ctools-use-modal')));
return $output;
}
function ajax_popup_call_test_modal_callback($js = FALSE) {
$output = t('<p>Lorem ipsum dolor sit amet...</p>');
$title = t('Modal ajax_popup_call');
$out = drupal_render(drupal_get_form('ajax_popup_call_form'));
if ($js) {
ctools_include('ajax');
ctools_include('modal');
ctools_modal_render($title,$out);
// above command will exit().
}else{
drupal_set_title($title);
return $output;
}
}
function ajax_popup_call_form($form,&$form_state){
$form['html'] = array(
'#type' => 'markup',
'#markup' => '<div id="show_elem"></div>',
);
$form['sub'] = array(
'#type' => 'submit',
'#value' => 'Click',
);
return $form;
}
my javascript is here.
jspage.js
jQuery(document).ready(function($){
$("#show_elem").html( my_js_func( 225, 300 ););
});
how do i call javascript function into a div tag of popup?