I have a Django project,now after clicking the url,it will directly trigger the function in veiws.py.
But I now want to add a JavaScript or bootstrap pop window, inside the window there are 2 buttons,cancel or confirm, only when confirm button has been clicked,the function in views.py will be called,otherwise if cancel is clicked, just return to pervious page.
url:
path('wLoadr/', wLoadr_func, name='wLoadr_func'),
template html:
<li><a class="dropdown-item" href="{% url 'wLoadr_func' %}">wLoadr</a></li>
views.py:
def wLoadr_func(request):
# there are some wLoadr_func code here .....omit code
return render(request, 'wLoadr/wLoadr_base.html')
pop window cancel and confirm button:
<button type="button" class="btn btn-secondary" id='cancel'>Cancel</button>
<button type="button" class="btn btn-primary" id='confirm'>Confirm</button>
Any friend can help?
It depends what Frontend framework you're using but you generally want to watch for the onclick event
As in: <button type="button" class="btn btn-primary" id='confirm' onclick="myFunction()">Confirm</button>
Where myFunction() would look something like `
function myFunction(){
$.get('http://someurl.com/wLoadr/wLoadr_base.html',function(data)
{
},'html');
}
` I'm shooting from the hip here because I'm not a frontend dev but the main point I'm trying to get at is you want to listen for the click event on the button and then route to that page
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.