29# created ajax functions for wishlist

This commit is contained in:
Eligiusz Kurzawa 2021-01-16 18:18:29 +01:00
parent cd4a4f95e7
commit e034fbd20a
2 changed files with 34 additions and 4 deletions

View File

@ -227,11 +227,14 @@
<div class="ml-auto d-flex"> <div class="ml-auto d-flex">
<a href="{% url 'jobs:single_job' job.slug job.pk %}" class="btn btn-primary py-2 mr-1">Apply Job</a> <a href="{% url 'jobs:single_job' job.slug job.pk %}" class="btn btn-primary py-2 mr-1">Apply Job</a>
<a href="#" class="btn btn-danger rounded-circle btn-favorite d-flex align-items-center"> <a href="javascripts:void(0);" title="Remove from my wish list" onclick="removefrommywishlist({{ job.id }})" class="btn btn-danger rounded-circle btn-favorite d-flex align-items-center">
<span class="icon-heart"></span>
</a>
<a href="javascripts:void(0);" title="Add to my wish list" onclick="addtomywishlist({{ job.id }})" class="btn btn-primary rounded-circle btn-favorite d-flex align-items-center">
<span class="icon-heart"></span> <span class="icon-heart"></span>
</a> </a>
</div> </div>
</div> </div>
</div> <!-- end --> </div> <!-- end -->
{% endfor %} {% endfor %}
@ -472,4 +475,30 @@
</div> </div>
</section> </section>
<script type="text/javascript">
function addtomywishlist(id) {
if (id){
$.ajax({
url:"/users/add-wishlist/" + id,
method:"GET",
success:function () {
alert("success")
}
});
}
}
function removefrommywishlist(id) {
if (id){
$.ajax({
url:"/users/remove-from-wishlist/" + id,
method:"GET",
success:function () {
alert("success")
}
});
}
}
</script>
{% endblock %} {% endblock %}

View File

@ -11,4 +11,5 @@ urlpatterns = [
path('employer-jobs/', EmployerPostedJobsView.as_view(), name='employer_jobs'), path('employer-jobs/', EmployerPostedJobsView.as_view(), name='employer_jobs'),
path('employee-messages/<int:pk>/', EmployeeMessagesView.as_view(), name='employer_messages'), path('employee-messages/<int:pk>/', EmployeeMessagesView.as_view(), name='employer_messages'),
path('employee-display-messages/<int:pk>/', EmployeeDisplayMessages.as_view(), name='employer_display_messages'), path('employee-display-messages/<int:pk>/', EmployeeDisplayMessages.as_view(), name='employer_display_messages'),
path('add-wishlist/<int:pk>/', EmployeeDisplayMessages.as_view(), name='employer_display_messages'),
] ]