How do I render a partial which contains a json object and iterate over the json object and appends it to where I want it too!! Frustration level 1000
So here is the Scenario of what I am trying to do
I have a view
= link_to admin_page_path(page), class: "edit-#{page.id}" do
.subcategory.btn.btn-xs.btn-info{"data-subcategory" => page.id}
View Subcategories
Here is my javascript
:javascript
$('.subcategory').on('click', function(e){
e.preventDefault();
row = $(this)
page_id = $(this).data('subcategory');
console.log(page_id);
Rails.ajax({
url: "/admin/pages/" + page_id,
type: "get",
dataType: "json",
success: function(data) {
/*render partial with data*/
},
error: function() {
console.log('the covids')
}
})
})
Here is the controller
def show
@page = Page.find(params[:id])
@page_subcategories = @page.subcategories
render json: @page_subcategories
how can I render a partial with the @page_subcategories json response?
end
How can I get @page_subcategories into a partial which than appends to the specific table row id
Please !