Re: Widgets not working for dynamically added formset forms

2019-10-08 Thread Dmitri S.
At first I hoped not to dive in JS and mostly use django things, but ok, 
now I see it's not that simple.
Thanks for help.

вторник, 8 октября 2019 г., 16:49:08 UTC+3 пользователь lemme smash написал:
>
> okay, i think i got it. you probably need to provide some snippet to 
> reload list of  choices to newly added form. try to look some examples of 
> using django-select2 with formsets...
> by pure js i mean not necessarily vanila js, but pure client code, without 
> rendering templates on server. all the problems you have partially (and 
> it's not only my opinion) happens because you trying to combine server-side 
> approach with client code pieces which is always buggy and hard to 
> implement and maintain.  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/730d35eb-542c-4eff-9359-0dbedb054856%40googlegroups.com.


Re: Widgets not working for dynamically added formset forms

2019-10-08 Thread lemme smash
okay, i think i got it. you probably need to provide some snippet to reload 
list of  choices to newly added form. try to look some examples of using 
django-select2 with formsets...
by pure js i mean not necessarily vanila js, but pure client code, without 
rendering templates on server. all the problems you have partially (and 
it's not only my opinion) happens because you trying to combine server-side 
approach with client code pieces which is always buggy and hard to 
implement and maintain.  

On Tuesday, October 1, 2019 at 11:41:28 PM UTC+3, Dmitri S. wrote:
>
> I have a formset with fields with Select2 widgets and a calendar 
> (date-picker) from django app.
>
> And I use dynamic addition of formset forms.
>
>
> When I render a template for the first time, all widgets work fine. *But 
> when I add new formset form, widgets of this new form don't work.*
>
>
> I think, this 
> 
>  ('formset:add') 
> is somehow related to my problem, but I can't figure how to use it.
>
> I also found this: 
>
> $('.django-select2').djangoSelect2();
>
> With this line dropdowns start working, but they become empty.
>
>
> For adding new form I use 'empty form' and this jQuery:
>
> 
> $('.buttons').on('click', '#add_form', function() {
> var form_idx = $('#id_resolution_set-TOTAL_FORMS').val();
> $('#form_set').append($('#empty_form').html().replace(/__prefix__/g, 
> form_idx));
> $('#id_resolution_set-TOTAL_FORMS').val(parseInt(form_idx) + 1);
> });
> 
>
>
> Form in HTML:
>
> {% if mat_id == None %}
>  enctype="multipart/form-data" method="post">
> {% else %}
>  enctype="multipart/form-data" method="post">
> {% endif %}
>
> {% csrf_token %}
> 
> {% for field in form_matter %}
> 
> {% if field.errors %}
> {{ field.errors }}
> {% endif %}
> {{ field.label_tag }}
> {{ field }}
> 
> {% endfor %}
> 
> RESOLUTIONS
>
> 
> {{ formset_resolutions.management_form }}
> {% for form in formset_resolutions %}
> 
> {% for hidden in form.hidden_fields %}
> {{ hidden }}
> {% endfor %}
> {% for field in form.visible_fields %}
> 
> {% if field.errors %}
> {{ field.errors }}
> {% endif %}
> {{ field.label_tag 
> }}
> {{ field }}
> 
> {% endfor %}
> 
> {% endfor %}
> 
> 
> ADD
> SAVE
> 
> 
> 
> {% for field in formset_resolutions.empty_form.visible_fields %}
> 
> {% if field.errors %}
> {{ field.errors }}
> {% endif %}
> {{ field.label_tag }}
> {{ field }}
> 
> {% endfor %}
> 
> 
> 
>
>
> Other scripts:
>
> 
> 
>
> {{ form_matter.media.js }}
>
>
> {{ form_matter.media.js }} are:
>
> 
>
> 
>  src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js">
>  src="/static/admin/js/admin/DateTimeShortcuts.js">
> 
>  src="/static/django_select2/django_select2.js">
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/132d7efe-3060-430c-826c-0aa5d6eaabae%40googlegroups.com.


Re: Widgets not working for dynamically added formset forms

2019-10-06 Thread Dmitri S.
I meant, when I click on Select2 widget (combobox with autocomplete), list 
of items does not show up. And when I click on calendar icon, calendar does 
not show up.

"It's better to use pure js" - what do you mean exactly? to make new forms 
duplicating existing rather than using django empty_form? or to make 
autocomplete and calendar with pure JS? or...?

воскресенье, 6 октября 2019 г., 17:42:49 UTC+3 пользователь lemme smash 
написал:
>
> okay, but what you actually mean by "widgets don't work"?
> also, from my experience I can say that when you have to work with some 
> dynamic forms is't much better to use pure js on client and only validate 
> it on backend
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/42e930ad-00fc-4ee7-9188-a706f5cdab9d%40googlegroups.com.


Re: Widgets not working for dynamically added formset forms

2019-10-06 Thread Dmitri S.
I meant, when I click on Select2 widget (combobox), list of items does not 
show up. And when I click on calendar icon, calendar does not show up.

"It's better to use pure js" - what to you mean exactly?

воскресенье, 6 октября 2019 г., 17:42:49 UTC+3 пользователь lemme smash 
написал:
>
> okay, but what you actually mean by "widgets don't work"?
> also, from my experience I can say that when you have to work with some 
> dynamic forms is't much better to use pure js on client and only validate 
> it on backend
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/61b4a377-79d2-4894-ac2f-0e18c9ba81cf%40googlegroups.com.


Re: Widgets not working for dynamically added formset forms

2019-10-06 Thread lemme smash
okay, but what you actually mean by "widgets don't work"?
also, from my experience I can say that when you have to work with some 
dynamic forms is't much better to use pure js on client and only validate 
it on backend

On Tuesday, October 1, 2019 at 11:41:28 PM UTC+3, Dmitri S. wrote:
>
> I have a formset with fields with Select2 widgets and a calendar 
> (date-picker) from django app.
>
> And I use dynamic addition of formset forms.
>
>
> When I render a template for the first time, all widgets work fine. *But 
> when I add new formset form, widgets of this new form don't work.*
>
>
> I think, this 
> 
>  ('formset:add') 
> is somehow related to my problem, but I can't figure how to use it.
>
> I also found this: 
>
> $('.django-select2').djangoSelect2();
>
> With this line dropdowns start working, but they become empty.
>
>
> For adding new form I use 'empty form' and this jQuery:
>
> 
> $('.buttons').on('click', '#add_form', function() {
> var form_idx = $('#id_resolution_set-TOTAL_FORMS').val();
> $('#form_set').append($('#empty_form').html().replace(/__prefix__/g, 
> form_idx));
> $('#id_resolution_set-TOTAL_FORMS').val(parseInt(form_idx) + 1);
> });
> 
>
>
> Form in HTML:
>
> {% if mat_id == None %}
>  enctype="multipart/form-data" method="post">
> {% else %}
>  enctype="multipart/form-data" method="post">
> {% endif %}
>
> {% csrf_token %}
> 
> {% for field in form_matter %}
> 
> {% if field.errors %}
> {{ field.errors }}
> {% endif %}
> {{ field.label_tag }}
> {{ field }}
> 
> {% endfor %}
> 
> RESOLUTIONS
>
> 
> {{ formset_resolutions.management_form }}
> {% for form in formset_resolutions %}
> 
> {% for hidden in form.hidden_fields %}
> {{ hidden }}
> {% endfor %}
> {% for field in form.visible_fields %}
> 
> {% if field.errors %}
> {{ field.errors }}
> {% endif %}
> {{ field.label_tag 
> }}
> {{ field }}
> 
> {% endfor %}
> 
> {% endfor %}
> 
> 
> ADD
> SAVE
> 
> 
> 
> {% for field in formset_resolutions.empty_form.visible_fields %}
> 
> {% if field.errors %}
> {{ field.errors }}
> {% endif %}
> {{ field.label_tag }}
> {{ field }}
> 
> {% endfor %}
> 
> 
> 
>
>
> Other scripts:
>
> 
> 
>
> {{ form_matter.media.js }}
>
>
> {{ form_matter.media.js }} are:
>
> 
>
> 
>  src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js">
>  src="/static/admin/js/admin/DateTimeShortcuts.js">
> 
>  src="/static/django_select2/django_select2.js">
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/09b7bf10-beb4-4a5d-8f27-3d597c9d18f8%40googlegroups.com.


Re: Widgets not working for dynamically added formset forms

2019-10-04 Thread Dmitri S.
and after clicking on widgets also no errors

пятница, 4 октября 2019 г., 17:58:22 UTC+3 пользователь Dmitri S. написал:
>
> Unchecked runtime.lastError: The message port closed before a response was 
> received. in Opera after page loading for the first time and no errors in 
> Chrome. When I add new form no other errors appear.
>
> пятница, 4 октября 2019 г., 10:41:58 UTC+3 пользователь lemme smash 
> написал:
>>
>> and you have no errors in browser console?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/70fbf215-9289-470e-939f-e4a4bcf0d1a5%40googlegroups.com.


Re: Widgets not working for dynamically added formset forms

2019-10-04 Thread Dmitri S.
Unchecked runtime.lastError: The message port closed before a response was 
received. in Opera after page loading for the first time and no errors in 
Chrome. When I add new form no other errors appear.

пятница, 4 октября 2019 г., 10:41:58 UTC+3 пользователь lemme smash написал:
>
> and you have no errors in browser console?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cc3c87ae-c736-4dc3-93dc-87470fbaf0aa%40googlegroups.com.


Re: Widgets not working for dynamically added formset forms

2019-10-04 Thread lemme smash
and you have no errors in browser console?

On Tuesday, October 1, 2019 at 11:41:28 PM UTC+3, Dmitri S. wrote:
>
> I have a formset with fields with Select2 widgets and a calendar 
> (date-picker) from django app.
>
> And I use dynamic addition of formset forms.
>
>
> When I render a template for the first time, all widgets work fine. *But 
> when I add new formset form, widgets of this new form don't work.*
>
>
> I think, this 
> 
>  ('formset:add') 
> is somehow related to my problem, but I can't figure how to use it.
>
> I also found this: 
>
> $('.django-select2').djangoSelect2();
>
> With this line dropdowns start working, but they become empty.
>
>
> For adding new form I use 'empty form' and this jQuery:
>
> 
> $('.buttons').on('click', '#add_form', function() {
> var form_idx = $('#id_resolution_set-TOTAL_FORMS').val();
> $('#form_set').append($('#empty_form').html().replace(/__prefix__/g, 
> form_idx));
> $('#id_resolution_set-TOTAL_FORMS').val(parseInt(form_idx) + 1);
> });
> 
>
>
> Form in HTML:
>
> {% if mat_id == None %}
>  enctype="multipart/form-data" method="post">
> {% else %}
>  enctype="multipart/form-data" method="post">
> {% endif %}
>
> {% csrf_token %}
> 
> {% for field in form_matter %}
> 
> {% if field.errors %}
> {{ field.errors }}
> {% endif %}
> {{ field.label_tag }}
> {{ field }}
> 
> {% endfor %}
> 
> RESOLUTIONS
>
> 
> {{ formset_resolutions.management_form }}
> {% for form in formset_resolutions %}
> 
> {% for hidden in form.hidden_fields %}
> {{ hidden }}
> {% endfor %}
> {% for field in form.visible_fields %}
> 
> {% if field.errors %}
> {{ field.errors }}
> {% endif %}
> {{ field.label_tag 
> }}
> {{ field }}
> 
> {% endfor %}
> 
> {% endfor %}
> 
> 
> ADD
> SAVE
> 
> 
> 
> {% for field in formset_resolutions.empty_form.visible_fields %}
> 
> {% if field.errors %}
> {{ field.errors }}
> {% endif %}
> {{ field.label_tag }}
> {{ field }}
> 
> {% endfor %}
> 
> 
> 
>
>
> Other scripts:
>
> 
> 
>
> {{ form_matter.media.js }}
>
>
> {{ form_matter.media.js }} are:
>
> 
>
> 
>  src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js">
>  src="/static/admin/js/admin/DateTimeShortcuts.js">
> 
>  src="/static/django_select2/django_select2.js">
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/06f8709b-8ee1-4dba-a9cf-ae4a9d0e81db%40googlegroups.com.