2012-02-09 41 views
0

我有下面的鏈接導軌3 JS遠程鏈路打開和印刷,而不是執行

<%= link_to "Comment", new_blog_post_comment_path(@blog_post, format: :js), 
remote: true, id: 'new_comment_link', class: 'btn' %> 

當按下時,代替執行new.js,我的瀏覽器顯示new.js.的文本 發生這種情況即使new.js爲空,或者只包含alert('lol');,所以我相當肯定,它不是一個JS錯誤

這是原來的new.js代碼,但我不認爲它很重要

$("<%= escape_javascript(render(:file => 'comments/new.html.erb')) %>") 
.insertAfter('#blog_post'); // Insert the comment form before the first comment 
$('#new_comment').slideDown(); 
$('#new_comment_link').hide(); 

回答

0

我認爲你需要與腳本標籤

<script type="text/javascript"> 
    $("<%= escape_javascript(render(:file => 'comments/new.html.erb')) %>") 
    .insertAfter('#blog_post'); // Insert the comment form before the first comment 
    $('#new_comment').slideDown(); 
    $('#new_comment_link').hide(); 
</script> 
+0

我不認爲它的工作原理一樣,...反正我嘗試過了,也沒有工作,它只是獲取與一起印刷包裝代碼視圖中