Django中的范围滑块

时间:2016-08-02 11:47:00

标签: html django html5 python-2.7 django-templates

我的模板中有一个范围滑块。我想在我的视图中调用Range Slider值更改的函数。

 /**
 * Created by Franz on 5/8/2016.
 */
import {Directive,provide} from '@angular/core';
import {NG_VALIDATORS} from '@angular/forms';
import {PASSWORD_REGEX} from '../../common/util/rejex';
import {Validator, AbstractControl} from "@angular/forms";

function validatePassword(control: AbstractControl) {
  return PASSWORD_REGEX.test(control.value) ? null : {
    validatePassword: {valid: false}
  };
}

@Directive({
  selector: '[validatePassword]',
  providers: [
    provide(NG_VALIDATORS, {
      useValue: validatePassword, // Alternative useExisting: PasswordValidator, but that creates and destroys objects every time.
      multi: true
    })
  ]
})
export class PasswordValidator implements Validator {
  constructor() {}

  validate(c: AbstractControl) {
    return PASSWORD_REGEX.test(c.value) ? null : {valid: false}
  };
}

我正在使用按钮和文字,我也从this

获得了帮助

Python 2.7.10 Django 1.9

1 个答案:

答案 0 :(得分:1)

假设您有public class TestFormFile : IFormFile { private string testFileContents; public TestFormFile(string testFileContent) { this.testFileContents = testFileContents; } public Stream OpenReadStream() { return new MemoryStream(Encoding.UTF8.GetBytes(testFileContents)); } // Implement Other methods and properties. } 来致电...

call_view(request)

注意:我使用了<input type="range" ... onchange="callFun(this.value)">

fetch

在您的视图功能中......

function callFun(value) {
    fetch('call_your_url/?value='+ value).then(function(response) {
        console.log(response.status);
    }
}