Skip to content

Commit fa30670

Browse files
committed
ScriptedMethodsTest.html - Update to use JSB v2 CefSharp.BindObjectAsync
1 parent 13c927a commit fa30670

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

CefSharp.Example/Resources/ScriptedMethodsTest.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ <h2>Javascript to .Net</h2>
3131
<button class="btn btn-primary" id="test-button" disabled>Click Me!</button>
3232
<p style="margin-top:40px"><a name="injected-code"><sup>1</sup></a>Javascript code that adds a click event listener and passes event data to .Net when the event occurs.</p>
3333
<pre data-shbrush="js">
34-
(function () {
34+
(async function ()
35+
{
36+
await CefSharp.BindObjectAsync("boundEvent");
3537
var counter = 0;
3638
var elem = document.getElementById('test-button');
3739
elem.removeAttribute('disabled');
38-
elem.addEventListener('click', function(e){
40+
elem.addEventListener('click', function(e)
41+
{
3942
if (!window.boundEvent){
4043
console.log('window.boundEvent does not exist.');
4144
return;

CefSharp.Example/ScriptedMethods.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ public static void ListenForEvent(this IFrame frame, string id, string eventName
119119
// Scripts should be minified for production builds. The script
120120
// could also be read from a file...
121121
var script =
122-
@"(function () {
122+
@"(async function ()
123+
{
124+
await CefSharp.BindObjectAsync('boundEvent');
123125
var counter = 0;
124126
var elem = document.getElementById('##ID##');
125127
elem.removeAttribute('disabled');

0 commit comments

Comments
 (0)