我的模板中有一个范围 slider 。我想在我的 View 中调用有关范围 slider 值更改的函数。
index.html
<input id="slider1" type="range" value="3" min="1" max="20" step="1" />
我正在使用按钮和文本,我还从 this 获得了帮助
Python 2.7.10 Django 1.9
最佳答案
假设您有 call_view(request)
调用...
<input type="range" ... onchange="callFun(this.value)">
注意:我使用了<a href="https://developers.google.com/web/updates/2015/03/introduction-to-fetch?hl=en" rel="noreferrer noopener nofollow">fetch</a>
function callFun(value) {
fetch('call_your_url/?value='+ value).then(function(response) {
console.log(response.status);
}
}
在你的 View 函数中...
def call_view(request):
request.GET.get('value')
return HttpResponse("success")
关于django - Django 中的范围 slider ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38719590/