2011-11-06 61 views
0

我有以下代碼,它返回第2行的語法錯誤sales.js:2SyntaxError: Expected token ')'這是什麼問題?與軌道jQuery語法錯誤

$('<div id="new_contact_dialog"></div>') 
.html('<%= escape_javascript render(:partial => 'choose_storage.html.erb') %>') 
.dialog({ 
    autoOpen: true, 
    modal: true, 
    title: 'Add a Contact%>', 
    buttons: { 'Create Contact' : function(){ $(this).find("form").submit(); }, 'Cancel' : function(){ $(this).dialog("close"); } }, 
    show: "fade", 
    hide: "fade", 
    width: 420 
}); 

回答

1

你在你的title: 'Add a Contact'線,這可能會使得實際呈現的JS扭曲有一個額外的%>,因爲你正在使用ERB。我建議在實際瀏覽器中檢查視圖的輸出;這可能有助於揭示它出了什麼問題。

除此之外,JS看起來像正確地解析出來。我使用http://jsbeautifier.org/來檢查它,這使查找圓括號的問題更容易追蹤。