Dachser Plugin
The Dachser plugin provides custom integration functionality for Dachser-specific requirements.
Overview
This plugin monitors the DOM for changes and triggers Dachser-specific functionality when elements are added to the page.
Features
- DOM Monitoring: Watches for dynamically added elements
- Auto-execution: Automatically calls Dachser data execution when ready
Requirements
The page must have window.dachserData with an execute method:
javascript
window.dachserData = {
execute: function() {
// Your custom Dachser logic
console.log('Dachser data execution triggered');
}
};How It Works
- The plugin sets up a MutationObserver to watch for DOM changes
- When new elements are added to the page, it checks for
window.dachserData - If
window.dachserData.executeexists and is a function, it calls it
Example Usage
javascript
// Define your Dachser data handler
window.dachserData = {
execute: function() {
// Custom logic to handle Dachser-specific functionality
console.log('Processing Dachser data');
// Example: Update elements, fetch data, etc.
const elements = document.querySelectorAll('.dachser-element');
elements.forEach(el => {
// Process element
});
}
};
// The plugin will automatically call execute() when elements are addedUse Cases
Dynamic Content Loading
Handle content that's loaded dynamically after page load:
javascript
window.dachserData = {
execute: function() {
// Process newly loaded content
const newArticles = document.querySelectorAll('.article:not(.processed)');
newArticles.forEach(article => {
article.classList.add('processed');
// Apply Dachser-specific processing
});
}
};Third-Party Widget Integration
Integrate with third-party widgets that load asynchronously:
javascript
window.dachserData = {
execute: function() {
// Check if third-party widget is loaded
if (window.ThirdPartyWidget) {
window.ThirdPartyWidget.init();
}
}
};