automatically fill slug field while typing
This commit is contained in:
parent
8bc8765035
commit
dd9cd7aa0c
|
@ -189,5 +189,5 @@ pyvenv.cfg
|
||||||
pip-selfcheck.json
|
pip-selfcheck.json
|
||||||
|
|
||||||
# End of https://www.gitignore.io/api/python,django
|
# End of https://www.gitignore.io/api/python,django
|
||||||
static/
|
/static/
|
||||||
local.env.yml
|
local.env.yml
|
||||||
|
|
|
@ -8,7 +8,8 @@ from passbook.core.models import Application, Provider
|
||||||
class ApplicationForm(forms.ModelForm):
|
class ApplicationForm(forms.ModelForm):
|
||||||
"""Application Form"""
|
"""Application Form"""
|
||||||
|
|
||||||
provider = forms.ModelChoiceField(queryset=Provider.objects.all().select_subclasses())
|
provider = forms.ModelChoiceField(queryset=Provider.objects.all().select_subclasses(),
|
||||||
|
required=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
function convertToSlug(Text) {
|
||||||
|
return Text
|
||||||
|
.toLowerCase()
|
||||||
|
.replace(/[^\w ]+/g, '')
|
||||||
|
.replace(/ +/g, '-')
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const $source = $('input[name=name]');
|
||||||
|
const $result = $('input[name=slug]');
|
||||||
|
|
||||||
|
const typeHandler = function (e) {
|
||||||
|
$result.val(convertToSlug(e.target.value));
|
||||||
|
}
|
||||||
|
|
||||||
|
$source.on('input', typeHandler) // register for oninput
|
||||||
|
$source.on('propertychange', typeHandler) // for IE8
|
|
@ -24,6 +24,7 @@
|
||||||
<script src="{% static 'js/jquery.min.js' %}"></script>
|
<script src="{% static 'js/jquery.min.js' %}"></script>
|
||||||
<script src="{% static 'js/bootstrap.min.js' %}"></script>
|
<script src="{% static 'js/bootstrap.min.js' %}"></script>
|
||||||
<script src="{% static 'js/patternfly.min.js' %}"></script>
|
<script src="{% static 'js/patternfly.min.js' %}"></script>
|
||||||
|
<script src="{% static 'js/passbook.js' %}"></script>
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
<div class="modals">
|
<div class="modals">
|
||||||
|
|
Reference in New Issue