私はDrupal 7でフォームAPIを使用してカスタムフォームを開発し、チェックボックスを使ってtableselectを開発しています。私は、jqueryでコード化したいチェックボックスを選択するための制約をいくつか持っています。私は、あなたがHEREを見ることができるようにdrupalの外でonclickチェックボックスの機能を作ったが、私がdrupalと統合しようとすると、jqueryセレクタは全く動作しない。ので、ここでDrupal 7 Form api Jqueryを使用したカスタムjavascript
はdrupalの中で私のコードです:
$form ['#attached'] ['js'] = array (drupal_get_path ('module',
'form_cuentacorriente') . '/checkboxes.js');
$form ['tabla'] = array (
'#type' => 'tableselect',
'#header' => $tabla ['header'],
'#options' => $tabla ['body'],
'#attributes' => array ('id' => 'conceptos')
);
、ここでは私のjsの関数である:
(function($){
$('input[type=checkbox]').click(function(){
var tabla = $("#conceptos")[0];
var long = tabla.rows.length;
var pos = $(this).closest("tr").index();
if (!this.checked){
for (i = pos+1; i < long +1; i++) {
$(tabla.rows[i]).find('input').prop('disabled', !this.checked).prop('checked', false);
}
}else{
$(this).closest("tr").next().find("input")
.prop('disabled', !this.checked);
}
});
})(jQuery);
私は*セレクタを使用している場合、それは私がクリックどこでも動作しますが、「入力[type = checkbox] 'does not work。
任意のアイデアのDrupal 7のjQueryの1.10バージョンでは、私が何をしないのですか?
ありがとうございます!
が、このおかげで解決: https://www.lullabot.com/articles/understanding-javascript-behaviors-in-drupal –