PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

jQuery conflict with Nextgen

  1. Hello.
    Just discovered this small script:

    http://www.gravityhelp.com/clearing-default-form-field-values-with-jquery/

    which exactly what I'm after, BUT it conflicts with the Nextgen gallery, getting som strange layout issues. I put the

    <?php wp_enqueue_script("jquery"); ?>
    <?php wp_head(); ?>

    in my header before the script.
    I found some posts recommending a no conflict mode, but know absolutely 0 about jQuery.

    thanks in advance.

    Posted 13 years ago on Tuesday August 23, 2011 | Permalink
  2. Can you post a link to your site where this conflict is visible? Thanks.

    Posted 13 years ago on Tuesday August 23, 2011 | Permalink
  3. Yes:

    http://www.ncfg.dk

    thanks.

    Posted 13 years ago on Wednesday August 24, 2011 | Permalink
  4. I found the form where you're using the jQuery here:
    http://ncfg.dk/tilmeld

    It seems to work fine, and there are no JavaScript errors. Is there another page where there ARE JavaScript errors or layout issues due to the addition of this script? Thanks

    Posted 13 years ago on Wednesday August 24, 2011 | Permalink
  5. Yes! All the pages with nextgen galleries has Javascript errors (ie front page). I am using image browser functionality in Nextgen plugin, but the wp_head somehow turn on a thickbox effect.
    Obviously I know nothing about jQuery, but maybe it's possible to make the wp_head() specific to the "clearit" script?

    Posted 13 years ago on Wednesday August 24, 2011 | Permalink
  6. Ahh, so you are including the clearit script on all pages, when it's really only needed on the one page? Are there other pages that require the script? We can make the code specific to that one page, or figure out what the conflict it. It will be pretty easy to include the clearit script on just the one page if that solution will work for you.

    Posted 13 years ago on Wednesday August 24, 2011 | Permalink
  7. Actually, I think the problem is that you were prepared to use jQuery.noConflict as $j, but you never did. All references to jQuery after the line that begins $var $j = should be changed to $j. Try this:

    [js]
    <script type="text/javascript">
    var $j = jQuery.noConflict();
    $j(document).ready(function() {
    	$j.fn.cleardefault = function() {
    	return this.focus(function() {
    		if( this.value == this.defaultValue ) {
    			this.value = "";
    		}
    	}).blur(function() {
    		if( !this.value.length ) {
    			this.value = this.defaultValue;
    		}
    	});
    };
    $j(".clearit input, .clearit textarea, #insearchbox input.field").cleardefault();
    });
    </script>
    Posted 13 years ago on Wednesday August 24, 2011 | Permalink
  8. I planning on embedding gravity forms on other pages too, and I like the fact, that the script also worked with the search functions/page!

    Unfortunately the revised script didn't work, but thanks.

    EDIT: It works now!

    I compared the code generated with and without wp_head(), and found that all kind of Nextgen code was there and these three lines:

    <script type='text/javascript' src='http://ncfg.dk/wp-includes/js/l10n.js?ver=20101110'></script>
    <script type='text/javascript' src='http://ncfg.dk/wp-includes/js/jquery/jquery.js?ver=1.6.1'></script>
    <script type='text/javascript' src='http://ncfg.dk/wp-includes/js/jquery/jquery.form.js?ver=2.73'></script>

    which seemed important :)

    so I replaced wp_head() with those three lines, and now both the script and Nextgen behaves.

    Thanks for your repsonse though. Tip top support.

    Posted 13 years ago on Thursday August 25, 2011 | Permalink
  9. I'm glad you got it sorted out.

    Posted 13 years ago on Thursday August 25, 2011 | Permalink

This topic has been resolved and has been closed to new replies.