Bonjour,

Avant, j'avais un textareacount qui apparaissait et fonctionnait correctement :
Code PHP : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
			<div class="comm_form">
				<form id="form_addCommentaire<?php echo $id_msg; ?>"
					name="form_addCommentaire<?php echo $id_msg; ?>"
					action="?addCommentaire=1" 
					method="post"
				>
				<div class="comm_photo_profil">
					<img src="images/profil/<?php echo ($_SESSION["coords"]["photo"] != '')?$_SESSION["coords"]["photo"]:'no-image.png'; ?>"
						width="30px" 
						height="30px"
					/>
				</div>
					<textarea id="msg_commentaire<?php echo $id_msg; ?>"
						name="msg_commentaire<?php echo $id_msg; ?>"
						class="msg_comm"
						onblur="javascript: if($('#msg_commentaire<?php echo $id_msg; ?>').val()==''){ $('#divFirstComment<?php echo $id_msg; ?>').hide(); }"
						onclick="javascript: $('#send_comment_button_<?php echo $id_msg; ?>').show();"
					></textarea>
					<input id="send_comment_button_<?php echo $id_msg; ?>"
						type="button"
						class="comm_button"
						onclick="ajouterCommentaire(<?php echo $_SESSION['coords']["id"].', '.$id_msg; ?>);"
						style="background-image: url('images/btn_send_comment.png');" 
<?php // TODO bouton à traduire ?>	
					/>
				</form>
			</div><!-- Fin comm_form -->
			<script type="text/javascript">
				$(document).ready(function()
				{
					var options3 = 
					{
						'maxCharacterSize': 260,
						'originalStyle': 'text_counter',
						'warningStyle': 'warningDisplayInfo',
						'warningNumber': 40,
						'displayFormat': '#input/#max'
					};
					$('#msg_commentaire<?php echo $id_msg; ?>').textareaCount(options3);
				});
			</script>
Mais comme le code ci-dessus était dans une boucle foreach($tab_messages as $id_msg => $info) ça faisait une sacrée répétition de code dans la page.

Et comme le formulaire de réponse n'apparait que lorsque l'utilisateur clique sur le lien Répondre du message auquel il souhaite répondre, j'ai voulu alléger le code de la page et déporter le formulaire en Ajax.
Code PHP : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
$html = '<form id="form_addCommentaire"
				name="form_addCommentaire"
				action="" 
				method="post"
		>';
$html .= 	'<textarea id="msg_commentaire"
					name="msg_commentaire"
					class="msg_comm"
					onclick="javascript: $(\'#send_comment_button\').show();"
			></textarea>';
$html .= 	'<input id="send_comment_button"
					type="button"
					class="comm_button"
					onclick="javascript: ajouterCommentaire('.$_POST['idmembre'].', '.$_POST['idmsg'].')"
					style="background-image: url(\'images/btn_send_comment_'.$_POST['langue'].'.png\');" 
			/>';
$html .= '</form>';
$html .= '<script type="text/javascript">';
$html .= 	'$(document).ready(function(){';
$html .= 		'var options3 = {';
$html .= 			"'maxCharacterSize': 260,";
$html .=			"'originalStyle': 'text_counter',";
$html .=			"'warningStyle': 'warningDisplayInfo',";
$html .=			"'warningNumber': 40,";
$html .=			"'displayFormat': '#input/#max'";
$html .=		'}';
$html .=		"$('#msg_commentaire').textareaCount(options3);";
$html .=	'});';
$html .= '</script>';
 
echo $html;
Je récupère bien ce $html dans la partie Javascript et le formulaire s'affiche, sauf le compteur de caractères !

Quelqu'un a une idée de la cause ?
Est-ce parce que $(document).ready n'arrive plus avec de l'Ajax ?