We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Execute a puzzle procedure from parent doc

Home Forums Programming Execute a puzzle procedure from parent doc

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #67413
    danielbruno
    Customer

    Hello all.

    I’m developing a furniture configurator using Webflow for the design of the page that will embed the Verge3D frame. I designed a color wheel selector that should trigger a puzzle procedure when the user clicks on a given color from the wheel. The color selection in the parent doc is correctly working and the issue I’m facing is to call the puzzle procedure from the parent’s <script> section.

    I tried loading v3d modules using:

      <script src="./v3d.js"></script>
      <script src="./visual_logic.js"></script>

    And to call the puzzle procedur I’m using:

            function handleClick_mela(sectorNumber) {
                var selectedColour = sectorNumber;
                var iframe = document.getElementById('susie_iFrame');
                iframe.contentWindow.v3d.Puzzles.call('atualizaCor', selectedColour );
            }

    But when I click on a given color on the wheel, I got the following error message:

    susie_productConfigurator.html:137 Uncaught TypeError: Cannot read properties of undefined (reading 'call')

    pointing to the line with the “iframe.contentWindow.v3d.Puzzles.call(‘atualizaCor’, selectedColour );” statement.

    Could anyone help me getting the puzzle procedure triggering by a script in the parent doc?

    Thank you so much!

    Daniel.

    #67416
    kdv
    Participant

    Assuming you procedure is named atualizaCor

    function handleClick_mela(sectorNumber) {
        var iframe = document.getElementById('susie_iFrame');
        iframe.contentWindow.v3d.puzzles.procedures.atualizaCor(sectorNumber);
    }

    The variable v3d.Puzzles doesn’t exist. Use v3d.puzzles or v3d.PL

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #67421
    danielbruno
    Customer

    Thanks a lot, @kdv

    You saved my day! :yahoo:

    Am I wrong or this exact method v3d.puzzles.procedures.PROC_NAME is not explicitly detailed on the documentation?

    Daniel.

    #67422
    kdv
    Participant

    It’s mentioned
    https://www.soft8soft.com/docs/manual/en/puzzles/Procedures.html#calling_procedures_javascript

    Procedures can be called either this way
    v3d.puzzles.procedures.my_cool_function();
    or this way (if they have spaces between words)
    v3d.puzzles.procedures['my cool function']();

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #67512
    danielbruno
    Customer

    It’s indeed there. But the way it is, it looks like the v3d namespace is already defined in the parent doc. I’d like to suggest that the full process is added to the docs.

    Thank you!

    • This reply was modified 1 year, 2 months ago by danielbruno.
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.