What are the Slack Archives?
It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
Hi Guys, i have a small problem in TS. Something is not working as expected... This is just a piece
Hi Guys, i have a small problem in TS. Something is not working as expected...
This is just a piece of ts script where the problem is located
async render(): Promise<void> { debug(this.stepEngineCode, '...fetchOnLoad'); const response = await this.ajaxProviderRender.fetch(); if (!response) { return; } if (this.ajaxContainerRender) { this.ajaxContainerRender.innerHTML = response; await mount(); this.stepEngineForm = <HTMLFormElement>this.getElementsByClassName(`${this.jsName}__form`)[0]; //this.stepEngineForm is here undefined -> why? this.mapStepEngineFormEvents(); } }
After put the response in container and re-mount the components my selector (this.stepEngineForm .....) just is always undefined
even if (i checked 1000times) the selector is correct and everything is fine... Due the undefined variable cannot be bind events to the form fetched...
This function render just render a form on-load of page... in the case i disable the fetchonLoad, the form is direclty rendered from twig and the same selector present in readyCallback
function works and the events are properly mapped..
I see that Spryker has in Core a similar case about quick-order-form (vendor/spryker-shop/quick-order-page/src/SprykerShop/Yves/QuickOrderPage/Theme/default/components/molecules/quick-order-form/quick-order-form.ts:95
) and it works as expected...
The code is very similar... but on my script just does not work..
Can anyone maybe help me? Thanks in advance.
Comments
-
guys, i found it... an error in html fetched content... sorry!
0 -
Hello Giovanni.
A little advice in code adjustment:if (!response || !this.ajaxContainerRender) { return; } this.ajaxContainerRender.innerHTML = response; await mount(); this.stepEngineForm = <HTMLFormElement>this.getElementsByClassName(`${this.jsName}__form`)[0]; this.mapStepEngineFormEvents();
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 75 Spryker News
- 921 Developer Corner
- 781 Spryker Development
- 88 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 34 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 25 Job Opportunities
- 3.2K 📜 Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random