Skip to content

Cannot understand ui.run_javascript() #3376

Closed Answered by python-and-fiction
snoman88 asked this question in Q&A
Discussion options

You must be logged in to vote

you should wait client connected.

async def get_client_lang():
    return await ui.run_javascript('navigator.language')

async def notify_lang():
    ui.notify(await get_client_lang())


@ui.page('/')
async def index():
    await ui.context.client.connected()
    lang = await get_client_lang()
    ui.button('get lang', on_click=lambda :ui.notify(lang))

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@snoman88
Comment options

Answer selected by snoman88
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants