Support » Fixing WordPress » How to change innerHTML with plugin content

  • sonatagu

    (@sonatagulbinaite)


    Hi, I need to change div content on button pressed. I am using Canvasio3D Light plugin and my div looks like this:

    <div id=”models” style=”width: 940px; margin:0 auto; display: block;”>
    [canvasio3D width=”940″ height=”390″ border=”1″ borderCol=”#F6F6F6″ dropShadow=”0″ backCol=”#FFFFFF” backImg=”https://automobiliai.ml/wp-content/uploads/2019/03/background1.jpg” mouse=”on” rollMode=”off” rollSpeedH=”0″ rollSpeedV=”0″ objPath=”https://automobiliai.ml/wp-content/uploads/2019/03/akena.obj” texturPath=”https://automobiliai.ml/wp-content/uploads/2019/03/akena_white.jpg” objScale=”1.5″ objColor=”” lightSet=”6″ reflection=”off” refVal=”5″ objShadow=”off” floor=”off” floorHeight=”0″ lightRotate=”off” vector=”off” mousewheel=”on” Help=”off”] [/canvasio3D]
    </div>

    This part of code works well but I want to change it (load new model) on button pressed and this part of code displays only like text:

    document.getElementById(“models”).innerHTML = ‘[canvasio3D width=”940″ height=”390″ border=”1″ borderCol=”#F6F6F6″ dropShadow=”0″ backCol=”#FFFFFF” backImg=”https://automobiliai.ml/wp-content/uploads/2019/03/background1.jpg” mouse=”on” rollMode=”off” rollSpeedH=”0″ rollSpeedV=”0″ objPath=”https://automobiliai.ml/wp-content/uploads/2019/03/akena.obj” texturPath=”https://automobiliai.ml/wp-content/uploads/2019/03/akena_white.jpg” objScale=”1.5″ objColor=”” lightSet=”6″ reflection=”off” refVal=”5″ objShadow=”off” floor=”off” floorHeight=”0″ lightRotate=”off” vector=”off” mousewheel=”on” Help=”off”] [/canvasio3D]’;

    Of course, I could create 27 divs with different models and show only 1 of them but plugin works only with 15 models in 1 web page and it would be a lot of code.. It is not working probably because it is not a HTML element but maybe somebody is facing it and know the best solution for this. I need to change only the texturPath of each model.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You cannot process shortcodes from plugins using JavaScript. It has to be done server side in post content. If you processed all the various models server side before serving the page, as you say, that would be a LOT of code. Your best choice would be to use Ajax to fetch the requested model each time a different one is needed. You can process shortcodes in Ajax callbacks by using do_shortcode(). As your Ajax callback would be creating the shortcode to “do”, you can specify whatever texturPath you want.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.