We have updated Flexmonster Software License Agreement, effective as of September 30, 2024. Learn more about what’s changed.

return container element or id

Answered
Michael T asked on April 19, 2022

is there a way that we can query the FM object to return the container property that was used to initialize it, or return the associated HTML DOM element ?
thank you,
stay safe
 

9 answers

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster April 20, 2022

Hello, Michael!
 
Thank you for writing to us.
 
Our team wants to inform you that there is a way to reach the container of Flexmonster component from the Toolbar.
You need to enable the Toolbar and use the flexmonster.toolbar.pivotContainer property to get the desired DOM element.
 
We have prepared a simple example for visualization: https://jsfiddle.net/flexmonster/9tdgkq6z/.
 
Please let us know if it helps.
 
Regards,
Solomiia.

Public
Michael T April 20, 2022

Thank you.
If possible, I think it would be lovely if one was able to get the pivotContainer regardless of whether or not the toolbar is enabled.
(It can make code more elegant when integrating FM)
Best,
M
 

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster April 21, 2022

Hello, Michael!

Thank you for your quick response.

Our team wants to ask you for more details about your use case:
1. Do you use any framework in your project?
2. In which way do you embed Flexmonster in your HTML page without directly using the id of the container element?
This information would greatly help us.

Looking forward to hearing from you.

Best regards,
Solomiia.

Public
Michael T April 28, 2022

Thank you.
I'm just using plain javascript. 
Looking to have javascript functions that can manipulate e.g. display: none etc. to the container.
Particularly for multi-FM pages, I keep a variable for each fmObject and fmContainer to be able to reference the flexmonster object and the container holding it.
It would be a nice simplification to allow just keeping a single variable instead. (the fmObject) and have it be able to tell me what the container is, without requiring the toolbar enabled.
 
Hope this helps!
Thank you,
 
 

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster April 28, 2022

Hello, Michael!
 
Thank you for the detailed explanation of your case.
 
We want to suggest keeping only one variable for each pivot - the container id.
Then, you can query this container and get the Flexmonster API like follows:

const flexmonsterAPI = document.getElementById("flexmonsterContainer")
                       .uielement.flexmonster;

 
You can read more about this approach in our docs: https://www.flexmonster.com/api/new-flexmonster/.
 
Kindly note this feature is available from the 2.8.31 version of Flexmonster.
Here is our upgrading to the latest version guide, if needed: https://www.flexmonster.com/doc/updating-to-the-latest-version/.
 
We hope it helps. Feel free to ask if any further questions arise.
 
Regards,
Solomiia.

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster May 5, 2022

Hello, Michael!

Hope you are having a great week.

Our team is wondering if you had a chance to try the suggested approach and get Flexmonster reference from the container. Could you please let us know if our response helped?

Looking forward to hearing from you.

Regards,
Solomiia.

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster May 12, 2022

Hello, Michael!

Hope you are doing well.

Just checking in to ask if our approach helped you get Flexmonster reference from the container.

We will be glad to hear your feedback.

Regards,
Solomiia

Public
Michael T May 24, 2022

Thank you. this works.

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster May 24, 2022

Hello, Michael!

Thank you for your feedback.

We are happy to hear that our approach works for your case.

Feel free ask if any further questions arise.

Regards,
Solomiia

Please login or Register to Submit Answer