1
0
-1

I have inserted some HTML elements through the custom JavaScript under UI builder settings, which its contents will be dynamically changed when entering the certain page of the menu. Initially, upon having the page loaded, the  added elements are displaying.


However, when clicking one of the menu within the Category, the added HTML elements are not changing anymore. I assume its because the whole page is only loaded at the start of the app, while clicking one of the menu will only reload the content within the main tag. 


I have tried in finding the approach to access the load event within this main tag, but have not been able to find it.


Can you assist in utilizing the addEventListener to detect the main tag content loaded each time clicking a new menu within the category to ensure that the HTML elements inserted through the custom JavaScript under UI builder settings keeps being updated?

    CommentAdd your comment...

    2 answers

    1.  
      3
      2
      1

      I found the solution at last. As stated in the comments, within the document.ready block, we need to access the page_loaded event and configure the HTML there.


      By referencing the current usage of page_loaded event on inbox element in the ajaxuniversal, I figured out we would then need to know the correct element for the page_loaded event to be successfully executed.


      After multiple times of trial and error, "page_loaded.link" works correctly as expected when we are clicking on the menu within the category.


      Example of the working code snippet can be seen as below.


      Cheers.

      1. Anders

        That's great! Could you share a working code snippet?

      2. NAS

        Sure, done editing the answer with the working code snippet.

      CommentAdd your comment...
    2.  
      1
      0
      -1

      Hi, perhaps you can inserting your custom elements within a document.ready block.

      1. NAS

        Hi,


        I already put the custom elements within the document.ready block, as shown below,  yet it still not loaded each time a menu within a category is clicked.


        However, I noticed that, whenever a menu within a category is clicked, the page_loaded event is being triggered, as underlined in image below. 


        Is it possible to access the event where the page_loaded is triggered to insert the custom elements?


        Thanks.

      CommentAdd your comment...