在 drupal 6.x 中的表单文本字段上按下 Enter 键时禁用页面重新加载
我有一个仅包含一个文本字段的表单,预期的行为是当用户在文本框中按 Enter 时,应该提交文本框的值,但不会重新页面(刷新)加载。 我尝试了各种设置 AHAH 的方法,但仍然无法实现预期的行为,页面会重新加载。 我一直在寻找解决这个问题的方法,但没有运气。
请建议如何完成或指导我到有用的地方 这是代码:
function user_porfile_message_form(){
$form = array();
$form['element1'] = array(
'#type' => 'textfield',
'#title' => '',
'#default_value' => '',
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#attributes' => array('class' => 'no-js'),
'#ahah' => array(
'path' => 'module/file/callback',
'wrapper' => 'some-wrapper',
'event' => 'click',
),
);
return $form;
}
I have a form containing one textfield only, and the expected behavior is that when user presses enter while in the text box the value of the text box should get submitted, but without re-page (refresh) load.
I have tried various ways of setting AHAH but still unable to achieve the expected behavior, the page reloads.
I have searched for any solution to this problem without luck.
Please advice how it has to be done or direct me somewhere useful
Here is code:
function user_porfile_message_form(){
$form = array();
$form['element1'] = array(
'#type' => 'textfield',
'#title' => '',
'#default_value' => '',
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#attributes' => array('class' => 'no-js'),
'#ahah' => array(
'path' => 'module/file/callback',
'wrapper' => 'some-wrapper',
'event' => 'click',
),
);
return $form;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到解决方案了,这里是:
Got the solution, here it is: