Jump to content

jquery and vanilla js

mrchow19910319
Go to solution Solved by mrchow19910319,

I fixed this issue by just doing this.

 

/*twitch.tv embed functions*/
new Twitch.Embed("twitch-embed", {
    width: 1800,
    height: 800,
    channel: "trick2g",
    layout: "video-with-chat",
    autoplay: false,
    theme: "dark"
});

 

I am making a site where I need to utilize youtube API as well as twitch API.
I followed this tutorial https://www.youtube.com/watch?v=9sWEecNUW-o and most of the js part was written in jquery.

but when it comes to the twitch API, the documentation examples were given in vanilla JS.

 

<html>
  <body>
    <!-- Add a placeholder for the Twitch embed -->
    <div id="twitch-embed"></div>

    <!-- Load the Twitch embed script -->
    <script src="https://embed.twitch.tv/embed/v1.js"></script>

    <!-- Create a Twitch.Embed object that will render within the "twitch-embed" root element. -->
    <script type="text/javascript">
      new Twitch.Embed("twitch-embed", {
        width: 854,
        height: 480,
        channel: "monstercat"
      });
    </script>
  </body>
</html>

now the issue I am facing is that if I embed the above code inside my HTML page, I can kind of got it working, but if I put it inside the app.js file, it does not work.

how do I convert the above code to jQuery?

If it is not broken, let's fix till it is. 

Link to comment
Share on other sites

Link to post
Share on other sites

I fixed this issue by just doing this.

 

/*twitch.tv embed functions*/
new Twitch.Embed("twitch-embed", {
    width: 1800,
    height: 800,
    channel: "trick2g",
    layout: "video-with-chat",
    autoplay: false,
    theme: "dark"
});

 

If it is not broken, let's fix till it is. 

Link to comment
Share on other sites

Link to post
Share on other sites

12 hours ago, mrchow19910319 said:

I fixed this issue by just doing this.

 


/*twitch.tv embed functions*/
new Twitch.Embed("twitch-embed", {
    width: 1800,
    height: 800,
    channel: "trick2g",
    layout: "video-with-chat",
    autoplay: false,
    theme: "dark"
});

 

That's the dyr

Link to comment
Share on other sites

Link to post
Share on other sites

6 hours ago, voiha said:

That's the dyr

?

If it is not broken, let's fix till it is. 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×