0
Drupal 7 Form Api를 사용하여 select 요소로 사용자 정의 폼을 작성하고 있습니다. #ajax 콜백을 첨부 할 예정이며, 변경 이벤트가 발생합니다.Drupal 7 # 아약스 변경 이벤트가 동일한 요소의 다른 변경 이벤트 처리기를 방지합니다.
$form['landing']['country'] = array(
'#type' => 'select',
'#options' => array(),
'#attributes' => array('class' => array('landing-country-list')),
'#validated' => TRUE,
'#prefix' => '<div id="landing-countries" class="hide">',
'#suffix' => '</div>',
'#title' => 'Select country',
'#ajax' => array(
'wrapper' => 'landing-cities',
'callback' => 'get_cities',
'event' => 'change',
'effect' => 'none',
'method' => 'replace'
),
);
하지만 문제는 js의 동일한 선택에서 사용자 정의 변경 기능을 사용할 수 없다는 것입니다. 이 함수에서 나는 선택된 옵션 값을 얻고 싶다. 그래서하지 않습니다 화재 :
$('body').on('change', 'select.landing-country-list', function() {
optval = $(this).find('option:selected').val();
});
이 코드는 파일에, 나는 $ 양식에 포함 : 당신의 도움에 미리
$form['#attached']['js'] = array(
'https://code.jquery.com/jquery-2.2.4.min.js',
drupal_get_path('module', 'landing') . '/landing.js',
);
감사합니다! 당신이 보내는 아약스 전에 잡을하려면