hi i need to use alert message when some wants delete a post ask her/him to delete or cancel
i tried this but this is a default alert browser
<button onclick="return confirm('are you sure you want to delete {{obj.title}}')" class="bt mx-auto"><a href="{% url 'posts:post-detail' obj.id %}"><img src="{% static 'icons/delete.svg' %}" alt=""></a></button>
i want to use this alert
alertify.prompt("are you sure you want to delete ", "{{obj.title}}",
function(evt, value ){
alertify.success('Ok: ' + value);
},
function(){
alertify.error('Cancel');
});
but i'm not sure where should i put that script in the template ? i use it inside the button delete , replacing to confirm() but seems doesnt work
thanks for helping ..
In order to achieve the desired result you need to change a bit your html in order to pass the current element (refer: this keyword) and like reported in the examples section you can attach to the window object a function called showAlert:
And change your button to: