AJAX jQuery click results in function event being fired twice
Posted
by pmagunia
on Stack Overflow
See other posts from Stack Overflow
or by pmagunia
Published on 2010-04-09T03:07:24Z
Indexed on
2010/04/09
3:13 UTC
Read the original article
Hit count: 353
I have an AJAX chat room module in Drupal and I am trying to insert BBCode stlye tex
tags to the submit box when the user clicks Insert Tex
. I managed to get the following code to work the first time but afterwards when I click Insert Tex
it inserts the tex
tags triple times.
$('#edit-chatroom-message-entry-submit').click(function (e) {
e.preventDefault();
e.stopPropagation();
if ($('#edit-chatroom-message-entry-box').val()){
Drupal.chatroom.postMessage($('#edit-chatroom-message-entry-box').val());
$('#edit-chatroom-message-entry-box').val('').focus();
}
});
$('#edit-chatroom-tex-submit').click(function (e) {
e.preventDefault();
e.stopPropagation();
$('#edit-chatroom-message-entry-box').val($('#edit-chatroom-message-entry-box').val() + '[tex][/tex]');
});
I would appreciate it if a suggestion could be make to make the code work properly.
© Stack Overflow or respective owner