including raw HTML node to canvas element

I want to combine canvas-slider-response plugin and RDK plugin to create response trial where observers change the coherence of the motion field using the slider.

The RDK plugin creates a canvas element and append it to the DOM to draw dots on the canvas. Because I want the slider function, inside of the RDK plugin, I added HTML element:

var html = '<div id="jspsych-canvas-slider-response-wrapper" style="margin: 100px 0px;">';
html += '<div id="jspsych-canvas-slider-response-stimulus">' + '<canvas id="jspsych-canvas-stimulus" height="' + trial.canvas_size[0] + '" width="' + trial.canvas_size[1] + '"></canvas>' + '</div>';
html += '<div class="jspsych-canvas-slider-response-container" style="position:relative; margin: 0 auto 3em auto; width:';

And then add that html variable to the html element with this method:

display_element.innerHTML = html;

Naturally, this overwrites on the canvas, shows the HTML element, but now the dots are gone (canvas is overwritten?).

I am somewhat aware that rendering HTML into a canvas is severely limited for security reasons. So tried some emulations:

1- I can render html element using creating SVG images:
Rendering HTML elements to <canvas>. But then I can’t interact with the images using the methods such as display_element.querySelector('#jspsych-canvas-slider-response-next').addEventListener('click', function () {}

2- I can also insertAdjacentHTML but with this method, the canvas element appears after the RDK element shows up at the screen – not together.
Add elements to the DOM given plain text HTML using only pure JavaScript (no jQuery).

3- I figured an HTML renderer in JsPsych could solve my problem here. So I tried including the RDK as a stimulus function to the canvas-slider-response, but I can’t find a way to call the function within the RDK plugin object. This is what I was trying to achieve:

var slider_trial = {
    type: 'canvas-slider-response',
    stimulus: function(c) {
        **callRDKPlugin(c);** ////// Something here /////
    labels: ['Exactly<br>the same','Totally<br>different'],
    canvas_size: [200, 500],
    prompt: '<p>How different would you say the colors of these two squares are?</p>',
    on_finish: function(data) {
        data.color1 = colors[0];
        data.color2 = colors[1];

Am I missing an easy step?

This is the desired image:

This is the desired image

144 thoughts on “including raw HTML node to canvas element”

  1. Good day I am so excited I found your webpage, I really found you by
    mistake, while I was browsing on Aol for something else, Regardless I am here now and would just
    like to say kudos for a tremendous post and a all round thrilling blog (I also love the theme/design),
    I don’t have time to browse it all at the minute but
    I have bookmarked it and also added your RSS feeds, so when I have time I
    will be back to read more, Please do keep up the fantastic work.

  2. Wonderful goods from you, man. I have be mindful your stuff previous to and you’re simply extremely great.
    I actually like what you have acquired right here, certainly like what you’re stating and the best way in which you say it.
    You’re making it enjoyable and you still take care
    of to stay it sensible. I can not wait to learn much more from you.
    That is actually a wonderful web site.

  3. Hello very nice website!! Guy .. Beautiful .. Wonderful ..
    I will bookmark your blog and take the feeds additionally?
    I’m glad to search out so many useful information here in the publish, we need work out extra techniques on this regard, thanks for sharing.
    . . . . .

  4. I’m extremely impressed along with your writing skills as smartly as with the structure on your weblog.
    Is this a paid subject matter or did you modify it your self?
    Anyway stay up the excellent high quality writing, it is uncommon to peer
    a great blog like this one today..

  5. Pingback: stromectol meaning
  6. Thanks on your marvelous posting! I really enjoyed reading it, you could be a great author.I will make
    sure to bookmark your blog and will eventually come
    back in the future. I want to encourage you to definitely continue your great writing, have a nice evening!

  7. Attractive section of content. I just stumbled upon your blog and in accession capital to assert that
    I get in fact enjoyed account your blog posts. Anyway I will be subscribing to your augment and even I achievement you access consistently fast.

  8. Appreciating the persistence you put into your blog and in depth information you present.
    It’s good to come across a blog every once in a while that isn’t the same old rehashed
    information. Great read! I’ve saved your site and I’m including your RSS feeds to my Google account.

  9. Hi, I do believe this is an excellent site. I stumbledupon it šŸ˜‰ I will return yet again since I saved as a favorite it.
    Money and freedom is the greatest way to change, may you be rich and continue to guide others.

  10. It’s a shame you don’t have a donate button! I’d certainly donate
    to this excellent blog! I guess for now i’ll settle for book-marking and adding your RSS feed to my Google
    account. I look forward to new updates and will share this blog with my Facebook group.
    Talk soon! ps4 ps4 games

  11. Pingback: deltasone reddit
  12. Pingback: ivermectin dosage
  13. Pingback: viagra 88
  14. Pingback: viagra soft tabs
  15. Pingback: canada drugs
  16. Pingback: best otc viagra
  17. It’s appropriate time to make some plans for the future and it’s time to
    be happy. I have read this post and if I could I desire to suggest
    you few interesting things or suggestions. Maybe you could write next articles referring
    to this article. I wish to read even more things about it!

  18. Nice blog right here! Also your web site quite a bit up fast!
    What host are you using? Can I am getting your associate hyperlink on your host?
    I desire my website loaded up as fast as yours lol

  19. Greetings! This is my first comment here so I just wanted to give a quick shout out
    and tell you I truly enjoy reading through your posts.
    Can you recommend any other blogs/websites/forums that deal with the same subjects?

  20. Its like you read my mind! You appear to know a lot about this, like you wrote the book
    in it or something. I think that you could do with
    some pics to drive the message home a little bit, but instead of that, this is magnificent blog.
    An excellent read. I’ll definitely be back.

  21. I’m more than happy to find this page. I need to to thank you for
    ones time due to this wonderful read!! I definitely enjoyed every little bit of it and i also have you book marked to see new stuff in your web site.

  22. Sweet blog! I found it while surfing around on Yahoo News.

    Do you have any tips on how to get listed in Yahoo News?
    I’ve been trying for a while but I never seem to get
    there! Cheers

  23. When someone writes an piece of writing he/she
    maintains the plan of a user in his/her mind that how a user can know
    it. Thus that’s why this paragraph is great. Thanks!

  24. My developer is trying to persuade me to move to .net from
    PHP. I have always disliked the idea because of the costs.
    But he’s tryiong none the less. I’ve been using WordPress on numerous websites for about a year and
    am nervous about switching to another platform.
    I have heard great things about Is there a way
    I can import all my wordpress posts into it?
    Any help would be really appreciated!

  25. Hi there! I know this is kinda off topic nevertheless
    I’d figured I’d ask. Would you be interested in exchanging links
    or maybe guest writing a blog post or vice-versa? My blog addresses a lot of the same subjects as
    yours and I believe we could greatly benefit from
    each other. If you happen to be interested feel free to send me an e-mail.
    I look forward to hearing from you! Excellent blog by the way!

  26. Hi, i think that i saw you visited my blog so i came to ā€œreturn the favorā€.I’m attempting to find things to
    improve my site!I suppose its ok to use some of your ideas!!


Leave a Comment