我无法在Rails 3部分中使用简单的input.hover。这是我的部分_lookupshow.html.erb
I threw the js include tags in the partial to see if that was the problem, it was
not the problem
<%= javascript_include_tag "jquery-ui-1.8.10.custom.min.js", "jquery.ui.mouse.min.js" %>
<table id="sortable" class="lkupdata">
<tbody class="lkuptbody">
<% @lookuprows.each do |lkup| %>
<tr class="lkuprow">
<td>
<input type="text" class="lkupcode" value="<%= lkup.codetype %>"/>
</td>
<td>
<input type="text" class="lkupdesc" value="<%= lkup.codedesc %>"/>
</td>
</tr>
<% end %>
</tbody>
</table>
这是application.js中的jquery代码,我把这个代码移到了lookup.js,它仍然没有用。
$('.lkupcode').load(function(){
$('.lkupcode').hover(function(){
alert("This is working");
});
});
我在document.ready部分中有上面的代码,但是将其移动到.load部分。知道为什么这么简单的东西不起作用吗?感谢...
答案 0 :(得分:0)
我不认为加载函数调用是正确的,它应该是
$(function() {
$('.lkupcode').hover(function() {
alert("This is working");
});
});
如果这不起作用,可能是您在文档正文中包含了jQuery UI;如果将它移到<head>
。