2013-10-07 43 views
1

我已經粘貼代碼下面創建的變量在JavaScript與導軌+ JavaScript的變量的Rails的JavaScript HAML變量創建

:javascript 
$(".form-control").each(function(index) { 


var mix = $(this).attr("id").split("_"); 
var e_array = mix.shift(); 
var e_name = mix.join("_"); 

var error = "#{@account.errors[:" + e_name +"]}"; 

//var error = error[":" + ]; 
alert(error); 



console.log("#{@account.errors}"); 
}); 

爲什麼數組返回空?

回答

0

試試這個"#{@account.errors['"+e_name+"']}";