テキストフィールドの値をリアルタイムで取得して表示するために ajax 変更イベントをどのように使用しますか (つまり、値が変更されるたびに新しい値が表示されます)。次のことを試しましたが#ajax['event']='change'
、テキストフィールドでは機能していないようです。Ajax 呼び出しは、テキスト フィールドがフォーカスを失った場合にのみトリガーされます。たとえば、テキスト フィールドに Hello を書き込むと、テキスト フィールドの外側をクリックするまで表示されません。これが私のコードです:-
function test1_form($form, &$form_state)
{
$form['text']=array(
'#title'=>'Text:',
'#type'=> 'textfield',
'#ajax'=> array(
'event'=>'change',
'callback'=>'test1_form_submit',
'wrapper'=>'contnr',
'method'=>'replace',
),
);
$form['up_button']=array(
'#title'=>t('Preview:'),
'#type'=>'markup',
'#prefix'=>'<div id="contnr">',
'#suffix'=>'</div>',
'#markup'=>'<h2>This is to be replaced</h2>',
);
return $form;
}
function test1_form_submit($form, $form_state)
{
return $form_state['values']['text'];
}
テキストフィールドの値をリアルタイムで取得し、drupal 7 モジュールのブラウザーに表示する方法はありますか?