I have a some modal forms, the link of those embedded in views result,
link are somethings linke share/nojs/2
, I register a menu in callback of the links,
It work correctly for root user, but I test it with 2 authenticated user, It work correctly for one of them and in another when I click link instead open modal form redirect me to /share/nojos/2
and tell me Javascript required,according to my codes,It means the javascript not load,
I really confused what happening and what can be reason of this ?
my codes :
$items['share/%ctools_js/%'] = array(
// 'page callback' => 'ym_alter_sharing_content',
'page callback' => 'ym_alter_sharing_callback',
'page arguments' => array(1),
'access callback' => 'user_is_logged_in',
'type' => MENU_CALLBACK,
);
function ym_alter_sharing_callback($js = FALSE) {
global $user;
// If people aren't using javascript, then I just boot em. sorry. its 2011.
if (!$js)
return "Javascript required";
// Include your ctools crap here
ctools_include('node.pages', 'node', '');
ctools_include('modal');
ctools_include('ajax');
// Create a blank node object here. You can also set values for your custom fields here as well.
$node = (object) array(
'uid' => $user->uid,
'name' => (isset($user->name) ? $user->name : ''),
'type' => 'share',
'language' => LANGUAGE_NONE,
);
$form_state = array(
'title' => t('sharing'),
'ajax' => TRUE,
);
$form_state['build_info']['args'] = array($node);
// change this to your type node form
$output = ctools_modal_form_wrapper('share_node_form', $form_state);
// This means the form has been exectued
if (!empty($form_state['executed'])) {
$output = array();
// Close the modal
$output[] = ctools_modal_command_dismiss();
// I use this method a lot on pages that have views, so what I do is get the latest view content
// with the latest node and replace the current view. magic!
/*
$html = views_embed_view('my_view', 'my_display';
$output[] = ajax_command_html('.view-display-id-my_display', $html);
*/
}
print ajax_render($output);
exit;
}