Skip to content

Commit

Permalink
[fix] Fixed location inline form on Django 4.2 #115
Browse files Browse the repository at this point in the history
In Django 4.2, the window name scheme for related object lookup
changed. This caused bug in triggering change event for the
location field.

Related to #115
  • Loading branch information
pandafy committed Jul 6, 2023
1 parent 49b9a07 commit 2565159
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions django_loci/static/django-loci/css/loci.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ input[type=text]{ width: 320px }
text-align: center;
font-size: 14px;
}
.form-row.field-geometry .flex-container {
display: block;
}
#floorplan_set-group{ display: none }
@media (max-width: 767px){
.field-geometry > div{
Expand Down
4 changes: 3 additions & 1 deletion django_loci/static/django-loci/js/loci.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ django.jQuery(function ($) {
// `dismissAddAnotherPopup()` in Django's RelatedObjectLookups.js to
// trigger change event when an ID is selected or added via popup.
function triggerChangeOnField(win, chosenId) {
$(document.getElementById(win.name)).change();
// In Django 4.2, the popup index is appended to the window name.
// Hence, we remove that before selecting the element.
$(document.getElementById(win.name.replace(/__\d+$/, ''))).change();
}
window.ORIGINAL_dismissRelatedLookupPopup = window.dismissRelatedLookupPopup;
window.dismissRelatedLookupPopup = function (win, chosenId) {
Expand Down

0 comments on commit 2565159

Please sign in to comment.