İçereği Atla
Menü
Bu soru işaretlendi
64 Görünümler

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
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Ağu 25
638
0
Ağu 25
367
0
Tem 25
1448
0
Tem 25
3
0
Tem 25
6