0
本当に簡単な質問です。Rails:htmlからjqueryを分離するには?
私はRuby on RailsでRedmineのプラグインを作成しています。私の "checkbox_enable.js" ファイルで、私はこれを持って
<table>
<tr>
<td >Specific operations/procedures</td>
<td>
<input type="checkbox" value="mfi_nam9" class="checkme"/>Other(please specify)<br/>
<input type="text" name="mfi_nam9" disabled="true" >
</td>
</tr>
<tr>
<td >General principles/strategies</td>
<td>
<input type="checkbox" value="mfi_nam8" class="checkme"/>Other(please specify):<br/>
<input type="text" name="mfi_nam8" disabled="true">
</td>
</tr>
</table>
# compatibility for use as redmine plugin
<% content_for :header_tags do %>
<%= javascript_include_tag 'checkbox_enable', :plugin => 'students' %>
<% end %>
:
$(function() {
$('.checkme').attr('checked', true);
$('.checkme').click(function(){
if($('input[name='+ $(this).attr('value')+']').attr('disabled') == false){
$('input[name='+ $(this).attr('value')+']').attr('disabled', true);
} else {
$('input[name='+ $(this).attr('value')+']').attr('disabled', false);
}
});
}
は、私は私のform.html.rbでこれを持ってthis
をしたいですそのファイルの私の最初の行を見てください。それが正しいかどうかわかりません。私は実際によくjavascriptとjqueryの違いを理解していない。しかし、javascriptはhtmlファイルに影響を与えません。
この作品を作成するにはどうすればよいですか?
EDIT:
私はバイオリンだけのjQuery 1.5のために働くことに気づきました。それともそうだ。つまり、多くのブラウザ(ほとんどのブラウザ)でうまく動作しない可能性がありますか?もしそうなら、誰もjqueryを何に使うのですか?
jsファイルにスクリプトリンクを追加しましたか?エラーはありますか? – Tinsten