Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

[Harlowe] Can I replace the contents of tw-sidebar using Javascript?

Hello everyone,

I wrote me a simple sidebar menu using javascript, which is toggled via a button and then slides in from the side. I already got it to work, but I would like to place the button that toggles the menu into the Harlowe sidebar and can't seem to get this to work.
I am new to javascript but I know that there is the possibility to call certain elements from a div-box or even the body and replace them with new strings. Would that also be possible with the tw-sidebar element?

To be clear: I want to replace the undo-redo-buttons or simply everyting in the tw-sidebar with my button that calls the sidebar to appear. If I place them in a passage, everything works fine already. I just want the button out of the way of the main content in the passages.

Comments

  • Yes, but because the sidebar is destroyed and re-created every time a passage is shown you will also need to execute the Javascript doing the sidebar replacement each time as well.

    I suggest you place the Javascript doing the replacement within a footer tagged passage.

    Without an example of your 'toggle button' code it is difficult to create a possible solution.
  • RueRue
    edited August 2016
    I'm confused. I wanted to answer, but got a message that my comment had to be approved first. Maybe because I forgot to post the code within the code-element?

    EDIT: Ok, that wasn't the problem, so I guess I'll just have to wait.
  • Sorry for the double post, but I am totally exited to work with twine right now and therefore somehow impatiened to wait.

    It seems I can't post anything (with code inside?) in this thread anymore, so here is just a link to an example of the code I used to build the sidenav. I used the "Sidenav Overlay Example".
    http://www.w3schools.com/howto/howto_js_sidenav.asp

    I read about the recreation of the tw-sidebar, but I had to post my script into every passage I wanted to have the sidebar in anyway, because the script didn't execute out of the javascript section and just resulted in an error.

    PS: Sorry to the admin, that has to curate all my post-trys here.
Sign In or Register to comment.