I want to implement simple feature.
When i click on checkbox
<%=check_box_tag :important_only,nil,false,id:'important-notes-only'%>
Data in view should be renewed
My controller action
def important_notes
deal = Deal.find(params[:id])
@notes = Note.where('is_important = ? and source_id = ?', true, deal.id)
p @notes
respond_to do |format|
format.html { }
format.js
end
end
route
get 'important/:id' => 'notes#important_notes', :as => 'important'
and important.js.erb
should render my partial on view after click
How to do it?
my ajax
$(document).ready(function(){
$('#important-notes-only').click(function () {
if ($('#important-notes-only').is(':checked')) {
console.log('clicked')
$.ajax({
type: "GET",
url: "<%= important_notes_path(@deal.id) %>",
success: render partial
}
})
}
});
}); How to render partial on success