place custom config of js in template

This commit is contained in:
Pierre-antoine Comby 2019-08-15 21:50:53 +02:00
parent 9fe47229fd
commit 70c5bc06f3
2 changed files with 7 additions and 5 deletions

View File

@ -220,8 +220,8 @@
formTemplate: null, // The jQuery selection cloned to generate new form instances formTemplate: null, // The jQuery selection cloned to generate new form instances
addText: 'add another', // Text for the add link addText: 'add another', // Text for the add link
deleteText: 'remove', // Text for the delete link deleteText: 'remove', // Text for the delete link
addCssClass: 'btn btn-primary', // CSS class applied to the add link addCssClass: '', // CSS class applied to the add link
deleteCssClass: 'btn btn-danger h-50 my-auto', // CSS class applied to the delete link deleteCssClass: '', // CSS class applied to the delete link
formCssClass: 'dynamic-form', // CSS class applied to each form in a formset formCssClass: 'dynamic-form', // CSS class applied to each form in a formset
extraClasses: [], // Additional CSS classes, which will be applied to each form in turn extraClasses: [], // Additional CSS classes, which will be applied to each form in turn
keepFieldValues: '', // jQuery selector for fields whose values should be kept when the form is cloned keepFieldValues: '', // jQuery selector for fields whose values should be kept when the form is cloned

View File

@ -7,7 +7,7 @@
{% csrf_token %} {% csrf_token %}
{% crispy formset helper %} {% crispy formset helper %}
<div class="form-actions"> <div class="form-actions">
<input type="submit" name="submit" value="Save" class="btn btn-primary" id="submit-save"> <input type="submit" name="submit" value="Add Members" class="btn btn-primary" id="submit-save">
</div> </div>
</form> </form>
@ -16,8 +16,10 @@
<script src="{% static 'js/dynamic-formset.js' %}"></script> <script src="{% static 'js/dynamic-formset.js' %}"></script>
<script> <script>
$('.formset-row').formset({ $('.formset-row').formset({
addText: 'add link', addText: 'add another', // Text for the add link
deleteText: 'remove' deleteText: 'remove', // Text for the delete link
addCssClass: 'btn btn-primary', // CSS class applied to the add link
deleteCssClass: 'btn btn-danger h-50 my-auto',
}); });
</script> </script>
{% endblock %} {% endblock %}