Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to reset .one() without refreshing page
    primarykey
    data
    text
    <p>i have a submit button that i attached a <code>.one()</code> mouse event to, cos otherwise if you accidentally double click it will send the information twice.</p> <p>the only problem is that once the information is sent, i refresh the containing <code>div</code> (i don't what the whole page to refresh) which then displays the new information. But if you go to add more information it won't allow you to click the submit button again as its already been clicked.</p> <p>i thought as im refreshing the <code>div</code> that it would reset....but it doesnt. how do i fix this?</p> <p>thanx</p> <p><strong>edit</strong></p> <p>so with the help of JOE ive done this. but it still fires twice on double click. have i done this right?</p> <pre><code> var clickActive = false; $("body").on("click", '.post_comment_button', function(e){ e.preventDefault(); if(clickActive) return; else { clickActive = true; var post = $(this).parents('.update_comment').parents('#post_comment'); var anchor = $(post).siblings('.comment_list').find('ul:first'); var comment = $(this).parents('.update_comment').children('textarea.post_comment').val(); var user = $(this).parents('.update_comment').children('input.user').val(); var msg_id = $(this).parents('.update_comment').children('input.message_id').val(); if (comment == '') loadComments(); else { $.post('messages.php', { comment: comment, message_id: msg_id, post_comment: 'true' }, function(data) { //create new comment// $('body').append(data); var newcomment = "&lt;li&gt;&lt;div class='comment_container'&gt;&lt;div class='date'&gt;less than 1 minute ago&lt;/div&gt;&lt;div class='name'&gt;" + user + " &lt;/div&gt;&lt;div class='info_bar'&gt;&lt;div class='edit_comment'&gt;&lt;a href='#' class='comment_edit'&gt;Edit&lt;/a&gt;&lt;/div&gt;&lt;span&gt;|&lt;/span&gt;&lt;a href='#' class='delete_comment'&gt;Delete&lt;/a&gt;&lt;/div&gt;&lt;div class='fadeOut_comment'&gt;&lt;div class='posted_comment'&gt; " + nl2br(htmlEntities(comment.trim())) + " &lt;/div&gt;&lt;/div&gt;&lt;/li&gt;"; $(post).slideUp(400); $(newcomment).fadeIn(500, function() { loadComments(); }).appendTo(anchor); clickActive = false; }); } } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload