script funziona solo una volta?!

fabio_198

Utente Attivo
8 Nov 2012
53
0
0
Salve ragazzi,
sto usando questo http://tutorialzine.com/2010/06/simple-ajax-commenting-system/#comment-79915 come sistema di commenti per il sito...funziona benissimo solo che praticamente è incluso in una pagina più volte per diversi ID

praticamente lo richiamo dentro una pagina che carica delle finestre modali col contenuto in ajax...il contenuto appunto è questo form per inviare i commenti.

praticamente funziona solo col primo id...con i restanti non va più...qualcuno mi saprebbe dare una mano? grazie in anticipo

questo è il .js

Codice:
$(document).ready(function(){
	/* The following code is executed once the DOM is loaded */
	
	/* This flag will prevent multiple comment submits: */
	var working = false;
	
	/* Listening for the submit event of the form: */
	$('#addCommentForm').submit(function(e){
         
 		e.preventDefault();
		if(working) return false;
		
		working = true;
		$('#submitcomm').val('Working..');
		$('span.error').remove();
		
		/* Sending the form fileds to submit.php: */
		$.post('submitcomm.php',$(this).serialize(),function(msg){

			working = false;
			$('#submitcomm').val('Submit');			
			if(msg.status){

				/* 
				/	If the insert was successful, add the comment
				/	below the last one on the page with a slideDown effect
				/*/

				$(msg.html).hide().prependTo('#main2').slideDown();
				$('#body').val('');
			}
			else {

				/*
				/	If there were errors, loop through the
				/	msg.errors object and display them on the page 
				/*/
				
				$.each(msg.errors,function(k,v){
					$('label[for='+k+']').append('<span class="error">'+v+'</span>');
				});
			}
		},'json');

	});
	
});
 
risolto ragazzi...se a qualcuno può interessare basta cambiare l'id dello script
$('#addCommentForm').submit(function(e){

in
$([id^='addCommentForm']").submit(function(e){

e così via anche con gli altri.

qualcuno può chiudere? grazie :byebye:
 

Discussioni simili