I am trying to generate a select_tag when the user clicks on a particular element. I have this JS in my page :
$(document).ready(function(){
$("#add_hotel").click(function(){
$(".new_hotels").append('<%=select_tag "dash_select", options_for_select(session[:user_hotel_list].collect{ |hotel| [hotel["name"], hotel["id"]] }) %>');
})
})
The resulting code looks like this :
<script>
$(document).ready(function(){
$("#add_hotel").click(function(){
$(".new_hotels").append('<select name="dash_select" id="dash_select">
<option value="31">Plaze</option>
<option value="30">dndjd</option></select>');
})
})
</script>
but I get Uncaught SyntaxError: Unexpected token ILLEGAL.
---EDIT---
The line with the error is this one :
$(".new_hotels").append( '<select name="dash_select" id="dash_select"><option value="31">Plaze</option>
<option value="30">dndjd</option></select>');
---EDIT---
Here's a picture of the exact line where I get the error in the console:
I noticed that when there is only one element in session[:user_hotel_list]
, the code works fine.
As was suggested it could be a problem linked to special hidden characters and copy paste issue, but I tried to write letter by letter the code and I still get this error...