django-jet icon indicating copy to clipboard operation
django-jet copied to clipboard

event 'formset:added' and 'formset:removed' not triggering in javascript admin customisation for CompactInline

Open dmnunez1993 opened this issue 8 years ago • 12 comments

Using CompactInline, when trying to bind a listener to the 'formset:added' and 'formset:removed' as per the documentation in https://docs.djangoproject.com/en/1.11/ref/contrib/admin/javascript/, the callback function is never executed. Having a look around at compact-inline.js I realized that the event itself is never triggered. Adding the trigger in the file and rebuilding with gulp does not seem to work either.

How should I aproach this??

dmnunez1993 avatar Aug 24 '17 03:08 dmnunez1993

What are you trying about it? Maybe is because django-jet don't use the django admin scripts.

SalahAdDin avatar Aug 28 '17 16:08 SalahAdDin

I just needed to attach a handler every time a new inline form is added to the admin to make some calculations on the inputs in the inline. Is there another event which is triggered when I add a new inline in CompactInline?

dmnunez1993 avatar Sep 01 '17 17:09 dmnunez1993

I don't know.

SalahAdDin avatar Sep 01 '17 21:09 SalahAdDin

Hi, Having the same problem when add any inline.

evandroao avatar May 24 '18 12:05 evandroao

@dmnunez1993 did you solve it?

SalahAdDin avatar May 24 '18 19:05 SalahAdDin

I think I find the problem, jet is doing this: $('.inline-group').on('inline-group-row:added', function(e, $inlineItem) { $inlineItem.find('.form-row').each(function() { self.initLinksForRow($(this)); }); });

In django 2 I supose the right is this: $(document).on('formset:added', function(event, $row, formsetName) { if (formsetName == 'author_set') { // Do something } }); https://docs.djangoproject.com/en/2.0/ref/contrib/admin/javascript/

I fix in my project rewrite some codes, but the better way is fix onde library.

evandroao avatar May 25 '18 22:05 evandroao

@evandroo, which library?

SalahAdDin avatar May 26 '18 20:05 SalahAdDin

@dmnunez1993 did you solve it?

I ended up using the default stacked inline with custom styling! Maybe if I find some time during the week I can have a look at the issue and send a PR, but I am not so sure. Do you guys have some sort of contributing guidelines?

dmnunez1993 avatar May 26 '18 20:05 dmnunez1993

@f1nality that is a question for you.

SalahAdDin avatar May 27 '18 01:05 SalahAdDin

@SalahAdDin, sorry man, I dont undestand. I talking about django-jet, when you try add inlines,

evandroao avatar May 28 '18 01:05 evandroao

On django-jet, i got it, but it @f1nality depends.

SalahAdDin avatar May 28 '18 03:05 SalahAdDin

+1

demoh2019 avatar Oct 03 '22 17:10 demoh2019