@@ -368,57 +368,56 @@ def update_output(value):
368
368
dash_duo .wait_for_text_to_equal ("#output-clientside" , 'Client says "hello world"' )
369
369
370
370
371
- def test_clsd009_clientside_callback_context (dash_duo ):
371
+ def test_clsd009_clientside_callback_context_triggered (dash_duo ):
372
372
app = Dash (__name__ , assets_folder = "assets" )
373
373
374
374
app .layout = html .Div (
375
375
[
376
- html .Button ("0" , id = {"btn" : 0 }),
377
- html .Button ("1" , id = {"btn" : 1 }),
378
- html .Button ("2" , id = {"btn" : 2 }),
376
+ html .Button ("btn0" , id = "btn0" ),
377
+ html .Button ("btn1:0" , id = {"btn1" : 0 }),
378
+ html .Button ("btn1:1" , id = {"btn1" : 1 }),
379
+ html .Button ("btn1:2" , id = {"btn1" : 2 }),
379
380
html .Div (id = "output-clientside" ),
380
- html .Div (id = "output-serverside" ),
381
381
]
382
382
)
383
383
384
- @app .callback (
385
- Output ("output-serverside" , "children" ), [Input ({"btn" : ALL }, "n_clicks" )]
386
- )
387
- def update_output (n_clicks ):
388
- return "triggered: %s" % dash .callback_context .triggered
389
-
390
384
app .clientside_callback (
391
385
"""
392
- function (n_clicks ) {
386
+ function (n_clicks0, n_clicks1 ) {
393
387
console.log(dash_clientside.callback_context)
394
388
return `triggered: ${JSON.stringify(dash_clientside.callback_context.triggered)}`
395
389
}
396
390
""" ,
397
391
Output ("output-clientside" , "children" ),
398
- [Input ({"btn" : ALL }, "n_clicks" )],
392
+ [Input ("btn0" , "n_clicks" ),
393
+ Input ({"btn1" : ALL }, "n_clicks" )],
399
394
)
400
395
401
396
dash_duo .start_server (app )
402
397
403
398
dash_duo .wait_for_text_to_equal (
404
- "#output-serverside " , " triggered: [{' prop_id': '.', ' value': None}]"
399
+ "#output-clientside " , r' triggered: [{" prop_id":"."," value":null}]'
405
400
)
401
+
402
+ dash_duo .find_element ("#btn0" ).click ()
403
+
406
404
dash_duo .wait_for_text_to_equal (
407
- "#output-clientside" , r'triggered: [{"prop_id":".","value":null}]'
405
+ "#output-clientside" ,
406
+ r'triggered: [{"prop_id":"btn0.n_clicks","value":1}]' ,
408
407
)
409
408
410
- dash_duo .find_element ("button[id*='0']" ).click ()
409
+ dash_duo .find_element ("button[id*='btn1 \" : 0']" ).click ()
411
410
412
411
dash_duo .wait_for_text_to_equal (
413
412
"#output-clientside" ,
414
- r'triggered: [{"prop_id":"{\"btn \":0}.n_clicks","value":1}]' ,
413
+ r'triggered: [{"prop_id":"{\"btn1 \":0}.n_clicks","value":1}]' ,
415
414
)
416
415
417
- dash_duo .find_element ("button[id*='2']" ).click ()
416
+ dash_duo .find_element ("button[id*='btn1 \" : 2']" ).click ()
418
417
419
418
dash_duo .wait_for_text_to_equal (
420
419
"#output-clientside" ,
421
- r'triggered: [{"prop_id":"{\"btn \":2}.n_clicks","value":1}]' ,
420
+ r'triggered: [{"prop_id":"{\"btn1 \":2}.n_clicks","value":1}]' ,
422
421
)
423
422
424
423
# TODO: flush out these tests and make them look prettier.
0 commit comments