تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
252 أدوات العرض

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.

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
أغسطس 25
70
1
أغسطس 25
679
0
أغسطس 25
413
0
يوليو 25
1626
0
يوليو 25
3