Markdown Previewer - Putting the markdown into the textarea

Hi, everyone.

I decided to try this one in jQuery. This is what I have for now, though.

I tried to put the same markdown as the one in the example app provided in the specification but I had trouble putting it in there as a string. What would be the best way to put it in there as a template string literal? For reference, here’s a link to the example.

Any help is appreciated. Thanks in advance.

Be sure to provide a link to the challenge that you’re working on to get help more readily. You can do so by clicking “Ask for Help” near the submission button on the challenge page to create a forum post from there.

Regarding this problem, I’m not sure if the tests will pass if you use jQuery, but it’s worth a shot. I’m more used to React, but a quick search found some ideas here and here.

It’s not a challenge. It’s a project. This one.

My bad. Looks like jQuery should be fine then! :smiley:

I figured out how to do put the markdown into the marked function as needed, but now I need to make it so that changes made to the markdown in the textarea are rendered to the #preview div as the user types. Should I make a new thread for that?

No new thread needed. :slight_smile:

jQuery offers “event listeners” for things like this. I recommend looking in to those as that should point you in the right direction :smiley:

Put an “on change” event on the text area and have the callback update the preview div?

Seems like the onchange event only fires when you focus out of the target input element. And in my case, right now I’m not seeing any changes in the preview even then. What did I do wrong? Here’s my code.

I do want to get the changes to appear in the preview when the user types or copy-pastes something into the editor element.

Edit: I think I need the input event. So editor.on("input", (event) => {...}); But how do I get this to work?

The test gives you a hint: it looks for the keyup event to fire the change. :slight_smile:

Then I have something wrong in the code aside from the event I’m trying to catch.

Is there anyone on here familiar with marked.js that can help me out? What am I doing wrong?