mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Adds one-shot function when a panel is displayed
This commit is contained in:
parent
b92ec751ef
commit
a1922bff81
@ -72,7 +72,9 @@ function activatePanel(panelName, options={}) {
|
|||||||
|
|
||||||
// Display the panel
|
// Display the panel
|
||||||
$(panel).addClass('panel-visible');
|
$(panel).addClass('panel-visible');
|
||||||
$(panel).fadeIn(100);
|
$(panel).fadeIn(100, function() {
|
||||||
|
$(panel).trigger('fadeInComplete');
|
||||||
|
});
|
||||||
|
|
||||||
// Un-select all selectors
|
// Un-select all selectors
|
||||||
$('.list-group-item').removeClass('active');
|
$('.list-group-item').removeClass('active');
|
||||||
@ -81,4 +83,24 @@ function activatePanel(panelName, options={}) {
|
|||||||
var select = `#select-${panelName}`;
|
var select = `#select-${panelName}`;
|
||||||
|
|
||||||
$(select).parent('.list-group-item').addClass('active');
|
$(select).parent('.list-group-item').addClass('active');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function onPanelLoad(panel, callback) {
|
||||||
|
// One-time callback when a panel is first displayed
|
||||||
|
// Used to implement lazy-loading, rather than firing
|
||||||
|
// multiple AJAX queries when the page is first loaded.
|
||||||
|
|
||||||
|
var panelId = `#panel-${panel}`;
|
||||||
|
|
||||||
|
$(panelId).on('fadeInComplete', function(e) {
|
||||||
|
|
||||||
|
// Trigger the callback
|
||||||
|
callback();
|
||||||
|
|
||||||
|
// Turn off the event
|
||||||
|
$(panelId).off('fadeInComplete');
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user