Add own JavaScript function to AimeosCatalogDetail.init()
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Add own JavaScript function to AimeosCatalogDetail.init()
Hi,
I've added a JavaScript file via TypoScript.
Now I want to call my own function additionally to the init() function in AimeosCatalogDetail.
For that I read your documentation here: https://aimeos.org/docs/Developers/Them ... ing_themes and copy your example:
That doesn't work. My debugger displays following error message: "TypeError: this.setupServiceSlider is not a function".
I think because of the decorator pattern the keyword "this" in AimeosCatalogDetail.init() has now a wrong context.
Can you help me with a working example please?
I've added a JavaScript file via TypoScript.
Now I want to call my own function additionally to the init() function in AimeosCatalogDetail.
For that I read your documentation here: https://aimeos.org/docs/Developers/Them ... ing_themes and copy your example:
Code: Select all
AimeosCatalogDetail.init = (function(fcn) {
var self = this;
return function() {
fcn();
self.setupYourMethod();
}
})(AimeosCatalogDetail.init);
I think because of the decorator pattern the keyword "this" in AimeosCatalogDetail.init() has now a wrong context.
Can you help me with a working example please?
Ubuntu 22.04.01
PHP 7.4.30
Typo3 v11.5.21 LTS
Aimeos web shop 22.10.4-pre3
PHP 7.4.30
Typo3 v11.5.21 LTS
Aimeos web shop 22.10.4-pre3
Re: Add own JavaScript function to AimeosCatalogDetail.init(
Can you post your code?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Add own JavaScript function to AimeosCatalogDetail.init(
I only have the following code from your documentation:
And I get this error message:
Ubuntu 22.04.01
PHP 7.4.30
Typo3 v11.5.21 LTS
Aimeos web shop 22.10.4-pre3
PHP 7.4.30
Typo3 v11.5.21 LTS
Aimeos web shop 22.10.4-pre3
Re: Add own JavaScript function to AimeosCatalogDetail.init(
Did you add the JS code after the aimeos-detail.js file is loaded?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Add own JavaScript function to AimeosCatalogDetail.init(
Yes, my JS file is the last line inside my <body> Tag.
Ubuntu 22.04.01
PHP 7.4.30
Typo3 v11.5.21 LTS
Aimeos web shop 22.10.4-pre3
PHP 7.4.30
Typo3 v11.5.21 LTS
Aimeos web shop 22.10.4-pre3
Re: Add own JavaScript function to AimeosCatalogDetail.init(
This does work properly and the docs have been adapted:
Code: Select all
AimeosCatalogDetail.setupYourMethod = function() {
console.log( 'test' );
};
AimeosCatalogDetail.init = (function(obj) {
init = AimeosCatalogDetail.init.bind(obj);
return function() {
obj.setupYourMethod();
init();
};
})(AimeosCatalogDetail);
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Add own JavaScript function to AimeosCatalogDetail.init(
Thank you for this example and your help!
I've found another solution as well:
With .call(AimeosCatalogDetail) I set the context correctly back to AimeosCatalogDetail.
I've found another solution as well:
Code: Select all
setupYourMethod = function() {
console.log( 'test' );
};
AimeosCatalogDetail.init = (function(fcn) {
var self = this;
return function() {
fcn.call(AimeosCatalogDetail);
self.setupYourMethod();
}
})(AimeosCatalogDetail.init);
Ubuntu 22.04.01
PHP 7.4.30
Typo3 v11.5.21 LTS
Aimeos web shop 22.10.4-pre3
PHP 7.4.30
Typo3 v11.5.21 LTS
Aimeos web shop 22.10.4-pre3