Jump to content

Multiple output CEF to js client


Sorginator

Recommended Posts

Hey guys,

I tried to trigger an event from CEF to client-side Javascript. It worked, but the event triggers 4x rather than just 1x.
At the CEF apparently, not, because that triggers only 1x, I have tested.
Nevertheless, 4 chatbox outputs arrive when I execute the following code...
Does anyone have any idea what this could be?

HTML & JS CEF

<head>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
	<link rel="stylesheet" href="style.css">
</head>

<body>
	<div class="all">
		<div class="Testdiv" id="TestDiv1"></div>
      	<script>
          document.getElementById("TestDiv1").addEventListener('click', function (event) {
            mp.trigger('testEvent1', event);
            var elem = document.getElementById("TestDiv1");
            elem.parentNode.removeChild(elem);
          });
     	</script>
	</div>
</body>

Clientside Script

mp.events.add('testEvent1', (testArg1) => {
	mp.gui.chat.push("Testtext: " + testArg1);
});

I also tried an alternative spelling in the script part of the HTML / Javascript code

$('#Testdiv').click(() => {
  mp.trigger('testEvent1', "Blabla");
});

 

 

Link to comment
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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...