Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
86 Weergaven

Hello Community,

I have a chatbot input field and a "Send" button in my form view.

Currently, when I click the Send button, my send_message() function is called.

Now I want the same function to be called when I press Enter inside the input field (without clicking the button).

Here is my code:


<div style="padding: 16px 24px; background: #fff; border-top: 1px solid #dee2e6; display: flex; align-items: center;">

    <field name="new_message" class="new-message-input" placeholder="Typing..." style="flex: 1 1 auto; margin-right: 10px;"/>

    <button name="send_message" string="Send" type="object" class="btn btn-primary" style="min-width: 80px;"/>

</div>


Input field:
<field name="new_message" class="new-message-input" placeholder="Typing..." style="flex: 1 1 auto; margin-right: 10px;"/>


Send button: 
<button name="send_message" string="Send" type="object" class="btn btn-primary" style="min-width: 80px;"/>



Expected Behavior:

When I press Enter inside the input field, send_message() should be triggered (just like clicking the button).

Question:

How can I bind the Enter key press event to call my send_message() function in an Odoo form view?

Thanks in advance.

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
aug. 25
644
0
aug. 25
371
0
jul. 25
1462
0
jul. 25
3
0
jul. 25
6