为什么这样做
<script type="text/javascript">
var mycallback = function() {
$('user_session_username').focus();
};
</script>
page.visual_effect :appear, 'user-response', :afterFinish => "mycallback"
以下两个陈述都不起作用
page.visual_effect :appear, 'user-response', :afterFinish => "$('user_session_username').focus()"
或
page.visual_effect :appear, 'user-response', :afterFinish => "$('user_session_username').focus"
答案 0 :(得分:1)
这是否有效:
page.visual_effect :appear, 'user-response', :afterFinish => "function(){$('user_session_username').focus()}"
注意:
link_to_function
适用于Rails 2.x但不适用于Rails 3.x. More info on this