Wednesday, November 25, 2015

Re: Django admin: is there an event, or another way to call a Javascript function, when a Django Admin Popup (the green plus icon) completes ?

Hi,

  I see this question is not receiving a lot of love. Perhaps we can try to approach it differently then:
 What is the mechanism that populates back the parentform select once the pop-up form is completed and saved ? (As I have very limited experience with front-end web technologies, I would not know where to look for the code implementing that functionnality).

From here, perhaps we can try to hook some custom Javascript.

Thank you for reading,
  Ad

Le vendredi 20 novembre 2015 09:55:10 UTC+1, boito...@gmail.com a écrit :
Hi,

  We are developing an application that relies on dynamic admin pages (based on some custom ajax). The high level idea is that, when the user changes the value in a select html element that is mapped to a ForeignKey on another model, we call a JS function (which triggers an asynchronous request that changes the current admin form on completion).


To achieve that, we listen to the change event of said select (to call the JS function when it is fired), which works fine when the user clicks a value directly in the drop-down menu proposed by the select.

Sadly, when this select is populated through the Admin Popup functionality (the process that starts by clicking the green plus icon to open a popup window, and that completes when the user click the save button on the popup window), it seems that the change event is not fired for the select, as our callback is not executed, even though the selected value is actually changed.

Is there another event we can listen to to get the same behaviour than when the user clicks a value directly from the list ? Or any other method to call our JS function when the select value is set through the popup completion ?

Thank you for reading,
  Ad

(Full disclosure: I first tried my luck with a question on SO, without great success)

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f9aa3420-d232-470e-bd36-ff094cf2eb55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment