function textarea_replace(that){
var charnum = $(that).attr('data-char'),
op = $(that).attr('data-op'),
target = $(that).find('h2'),
textarea = $(target).next('textarea'),
testo = $(target).text();
$(target).next('textarea').val(testo).show().focus();
$(target).css({ 'display': 'none' });
$(textarea).on({
blur: function(e){
e.stopPropagation();
testo_fin = $(this).val()
if (testo_fin.length > charnum) {
var text_cut = testo_fin.substr( 0, charnum )
$(this).prev().css({ 'display': 'block' }).text(text_cut)
} else {
$(this).prev().css({ 'display': 'block' }).text(testo_fin)
}
$(this).hide();
$(textarea).off('blur');
send_textarea(op, testo_fin, url_global);
}
});
}
I call it whith a event handler
$('.edit_box').on({
click: function(e){
$('.edit_box').off('click');
that = $(this)
textarea_replace(that);
}
});
i don't understand how can i temporary stop and re active the click event, because if i click on the textarea it calls another event and send the text 2 (or more times).