appendElement

approg
approg Community Member Posts: 258 ♪ Opening Act ♪
I'm trying to create a small "plugin" for Lectora 17 seamless that will dynamically add HTML elements, such as images, to the page. After some research I found that Trivantis has provided the helper function:
appendElement(obj, parentElement, htmlElement);

Unfortunately whatever I try results in the same thing - nothing added to the title.

I put an image, fred.jpg, in the same folder as the published title and then when
appendElement(null, null, "");
is called it throws no errors but also doesn't display the image.

Can anyone help with this?

Comments

  • mnotermans5114
    mnotermans5114 Community Member Posts: 916
    First thing that comes to mind, is that it cannot find the fred.jpg
    Did you add it to the 'images' folder ?

    I use a dynamic method to add/create elements in my courses in several projects i showed the community.
    In this one i add the circles and numbers around the specific images on the page when clicking 'show array index'
    http://community.trivantis.com/shared-content/random-animation-with-javascript/
    Although its in a old version ( Lectora X10 ), i do think you might find something usefull in the code.

    This one has it too...
    http://community.trivantis.com/shared-content/reusable-oop-setup-in-lectora/

    Kind regards,

    Math
  • approg
    approg Community Member Posts: 258 ♪ Opening Act ♪
    Thanks for that. Unfortunately neither work when the title is published with Lectora 17 seamless - my browser throws JS errors.
  • approg
    approg Community Member Posts: 258 ♪ Opening Act ♪
    I solved it.

    Without really styling it, the image is placed inline and so, in my case, off the bottom of the title. With appropriate CSS (eg position:absolute; left:0; top:0; z-index:1000;) the image appears as expected.
  • mnotermans5114
    mnotermans5114 Community Member Posts: 916
    Yeah older versions Javascript often fail in seamless. Mostly because the DOM cannot be found, Lectora 17 however has a method to get the proper DOM/document element, so fixing that in the script(s) should make them work.

    Math
  • approg
    approg Community Member Posts: 258 ♪ Opening Act ♪
    Are you working on the premise that if you tell me the answer then I'll never work it out for myself ;-)