Fixed #26357 -- Allowed admin popups to work on links added after page load.

This commit is contained in:
Julian Andrews 2016-03-15 10:11:34 -06:00 committed by Tim Graham
parent 6fdb12cdcc
commit adc93e8599
3 changed files with 8 additions and 2 deletions

View File

@ -162,7 +162,7 @@
}
});
$('.related-widget-wrapper select').trigger('change');
$('.related-lookup').click(function(e) {
$('body').on('click', '.related-lookup', function(e) {
e.preventDefault();
var event = $.Event('django:lookup-related');
$(this).trigger(event);

View File

@ -4,7 +4,7 @@
'use strict';
$(document).ready(function() {
var modelName = $('#django-admin-form-add-constants').data('modelName');
$('.add-another').click(function(e) {
$('body').on('click', '.add-another', function(e) {
e.preventDefault();
var event = $.Event('django:add-another-related');
$(this).trigger(event);

View File

@ -24,6 +24,12 @@ Code style
JSHint will be run when you run the JavaScript tests. We also recommended
installing a JSHint plugin in your text editor.
* Where possible, write code that will work even if the page structure is later
changed with JavaScript. For instance, when binding a click handler, use
``$('body').on('click', selector, func)`` instead of
``$(selector).click(func)``. This makes it easier for projects to extend
Django's default behavior with JavaScript.
.. _javascript-patches:
JavaScript patches