Answer the question
In order to leave comments, you need to log in
How to add new options to select in Rails_admin via js/coffee?
Hey!
I'm trying to make dependent selects using js/coffee. After selecting a value from the first select, I send a request for new options for the second select. After that, using append, I append them to the second select. But for some reason, they are not displayed in rails_admin if you try to open the second select. Has anyone experienced something similar? I would be grateful for any help!
dependent_pages.js.coffee:
$(document).ready ->
$('#parent_site').change ->
$.ajax '/admin/get_depended_pages?site_id=' + this.value,
type: 'POST'
dataType: 'html'
error: (jqXHR, textStatus, errorThrown) ->
alert("#{textStatus}: #{errorThrown}")
success: (data, textStatus, jqXHR) ->
pages = $('#page_parent_id')
pages.empty()
data = jQuery.parseJSON(data)
for element in data
console.log element
pages.append($("<option></option>").attr("value", element[1]).text(element[0])).html()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question