mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Simplified SelectFilter2 with Element.closest().
https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
This commit is contained in:
parent
99cefea360
commit
9cf4e40b84
@ -6,14 +6,6 @@ Requires jQuery, core.js, and SelectBox.js.
|
|||||||
*/
|
*/
|
||||||
(function($) {
|
(function($) {
|
||||||
'use strict';
|
'use strict';
|
||||||
function findForm(node) {
|
|
||||||
// returns the node of the form containing the given node
|
|
||||||
if (node.tagName.toLowerCase() !== 'form') {
|
|
||||||
return findForm(node.parentNode);
|
|
||||||
}
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
window.SelectFilter = {
|
window.SelectFilter = {
|
||||||
init: function(field_id, field_name, is_stacked) {
|
init: function(field_id, field_name, is_stacked) {
|
||||||
if (field_id.match(/__prefix__/)) {
|
if (field_id.match(/__prefix__/)) {
|
||||||
@ -154,7 +146,7 @@ Requires jQuery, core.js, and SelectBox.js.
|
|||||||
SelectFilter.refresh_icons(field_id);
|
SelectFilter.refresh_icons(field_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
findForm(from_box).addEventListener('submit', function() {
|
from_box.closest('form').addEventListener('submit', function() {
|
||||||
SelectBox.select_all(field_id + '_to');
|
SelectBox.select_all(field_id + '_to');
|
||||||
});
|
});
|
||||||
SelectBox.init(field_id + '_from');
|
SelectBox.init(field_id + '_from');
|
||||||
|
Loading…
Reference in New Issue
Block a user