• I have the following plugins installed and acitviated:

    • Meenews newsletter subscription
    • Lightbox 2 for images</li?

    Meenews works fine with the following jQuery I have in my header:

    <script type='text/javascript'>
    		// Form 
    
    		$(document).ready(function(){
            	$('#send_message').click(function(e){
    				// Stop the form from being submitted
                	e.preventDefault();
    	            var error = false;
        	        var name = $('#name').val();
            	    var email = $('#email').val();
    
                	if(name.length == 0){
                    	var error = true;
                    	$('#name_error').fadeIn(500);
                	}else{
                    	$('#name_error').fadeOut(500);
                	}
                	if(email.length == 0 || email.indexOf('@') == '-1'){
                    	var error = true;
                    	$('#email_error').fadeIn(500);
                	}else{
                    	$('#email_error').fadeOut(500);
                	}
    
                	if(error == false){
                    // Disable the submit button to avoid spamming
                    // Change the button text to Sending...
                    $('#send_message').attr({'disabled' : 'true', 'value' : 'Sending...' });
                    $.post("http://www.designcymru.com/contact/testr/send_email.php", $("#contact_form").serialize(),function(result){
    		           	if(result == 'sent'){
                             $('#cf_submit_p').remove();
                             $('#mail_success').fadeIn(500);
                        }else{
                             $('#mail_fail').fadeIn(500);
                             $('#send_message').removeAttr('disabled').attr('value', 'Send The Message');
                        	}
                    	});
                	}
            	});
        	});
    
     		</script>

    …but when I activate Lightbox 2 it doesn’t work. If I add
    var $j = jQuery.noConflict();
    and replace all ‘$’ with ‘$j’ Lightbox works but Meenews doesn’t.

    I am trying to figure out what I can do to avoid the jQuery<script> in my header from conflicting with any plugins. Any ideas? I’ve trailed the net and having no luck in figuring this out.

The topic ‘How do I avoid Query scripts from conflicting with plugins in WP?’ is closed to new replies.