ruby on rails - Want to add dynamic list with dynamic data through js -


there main file in want add li in ul dynamic value.

<ul class="selected_questions"></ul> 

in js.erb want show title. have debugged , @ques value there not showing in ul. following code.

<% if @ques.errors.any? %>  console.log('error'); $('#dialog-form').html('<%= escape_javascript(render('form')) %>'); <% else %> console.log('created'); $(".selected_questions").append('<li><span class="tab">"'+@ques.title+'"</span></li>'); $('#dialog-form').dialog('close'); $('#dialog-form').remove(); <% end %> 

i have tried following way :

$('<li />', {html: @ques.title}).appendto('ul.selected_questions') 

simple string appended object controller not been shown. doing wrong ???

try

change this

 $("#selected_questions").append('<li><span class="tab">"'+@ques.title+'"</span></li>'); 

to

$("#selected_questions").append('<li><span class="tab"><%= @ques.title %></span></li>'); 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -