Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

As great as the jQuery Tools might be they're giving me a headache. I want something like this for my website.

I have the necessary script included (and Scrollable works just fine btw.):

<script src="http://cdn.jquerytools.org/1.2.5/tiny/jquery.tools.min.js"></script>

I followed the minimal setup and also copied and pasted the source code from the standalone version. For some reason the content doesn't show up! If I get rid of the "display:none" command in the CSS the content shows up but overlayed. I'm not sure why it's not working. Please see here.

EDIT: So, many days later I'm trying to get all the script calls out of my header and put them into my function.php instead. I also want to try and use no conflict wrappers. As far as I understand I should use

jQuery(document).ready(function($) {

instead of

$(document).ready(function(){

I found the latter in the contact.php of my parent theme. I replaced it with the first code and it stopped working!!

Here's the whole script of the contact.php:

 <script type="text/javascript">
$(document).ready(function(){
              $('#contact').ajaxForm(function(data) {
                 if (data==1){
                     $('#success').fadeIn("slow");
                     $('#bademail').fadeOut("slow");
                     $('#badserver').fadeOut("slow");
                     $('#contact').resetForm();
                     }
                 else if (data==2){
                         $('#badserver').fadeIn("slow");
                      }
                 else if (data==3)
                    {
                     $('#bademail').fadeIn("slow");
                    }
                    });
                 });
        </script>

Any idea why it doesn't work?

I checked the jquery.form.js that it's based on and could it have to do something with that?

jQuery Form Plugin
 * version: 2.07 (03/04/2008)
 * @requires jQuery v1.2.2 or later
 *
 * Examples at: http://malsup.com/jquery/form/
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id$
 */
 (function($) {
/**
 * ajaxSubmit() provides a mechanism for submitting an HTML form using AJAX.
 *

I need to fix all of this step by step, so I hope you'll help me out a bit here, thanks :)

I really appreciate any hint you can give me. I tried to implement the scripts in the function.php instead of the header, but for some reason the scripts stop working then, so it's not an option.

share|improve this question
    
you've got multiple copies of jQuery loading... again. –  Milo Sep 12 '11 at 5:25
    
Only 2, right? The one in the function.php and the one in the header.php that I can't remove because another plugin will stop working (the contact form of my parent theme). I already tried to change that, but it didn't work (as explained in another thread where nobody seemed to know what's wrong anyways). –  japanworm Sep 12 '11 at 13:31
1  
I think the reason no one is giving you answers is because it's mostly nothing to do with WordPress, and everything to do with JavaScript, which is, honestly when I look at all your code, just an absolute mess. Trying to use two versions of jQuery because a form doesn't work without a particular one is ridiculous. My advice: start over with one single script/element at a time, get it working correctly, and ask more concise questions if you have problems. A wall of code and "what's wrong?" is not going to get you answers. –  Milo Sep 12 '11 at 15:04
    
Thank you for your honest answer. I'll try to clean up this mess somehow! –  japanworm Sep 13 '11 at 1:08
    
Hello again. I'm still trying to get this to work. I updated my question, so if you could help me, that would be great! :) –  japanworm Sep 18 '11 at 7:39
add comment

1 Answer

up vote 2 down vote accepted

If it doesn't work anyway, what is the harm of trying to do it right way?

  1. You do not use wp_enqueue_script() for most of scripts. You should.

  2. Loading two copies of jQuery is wrong. The fact that trying to fix it breaks something does not make it less wrong.

  3. From quick look you have a lot of inline JavaScript and not using noConflict wrappers consistently, see link above for details.

share|improve this answer
    
Thank you very much for your answer. I've been reading through this website several times and I'm still not sure how exactly I'm supposed to implement it correctly into Wordpress, so I hope you don't mind me asking. In which php file should I include the php function command? In the header? In the function.php? Only where I want the plugins to work? Also, when I want to call my scripts in no conflict mode I found so many different codes for it that I'm not sure which one I'm supposed to use. E.g. jQuery(document).ready(function($) or jQuery.noConflict(); (function($) { $(function() { –  japanworm Sep 13 '11 at 1:19
1  
@japanworm You should include your code in functions.php, but hook function to wp_enqueue_scripts rather than execute immediately. As above Codex articles have examples of noConflict wrappers - you can wrap in different ways, there is more than one way that will work. –  Rarst Sep 13 '11 at 8:56
    
Thank you very much! I want to confirm again (sorry for being so slow!): So I'd add a code like this to my function.php: add_action('wp_enqueue_scripts','my_theme_scripts_function'); function my_theme_scripts_function() { wp_enqueue_script('jquery'); wp_enqueue_script('nivoSlider', get_stylesheet_directory_uri() . '/js/jquery.nivo.slider.pack.js'); wp_enqueue_script('superfish', get_stylesheet_directory_uri() . '/js/superfish.js'); wp_enqueue_script('', get_stylesheet_directory_uri() . '/js/custom.js'); } and then do I also have to add something in addition to that into my header.php? –  japanworm Sep 13 '11 at 14:18
    
I'm still not sure how to do it and didn't get it to work. Could somebody please answer my question of the last comment? –  japanworm Sep 15 '11 at 14:04
    
@japanworm please add newer code to your question, comments are not suitable for it. Other than enqueues you still need inline scripts in your header (I won't go into more complex ways of adding it for now). –  Rarst Sep 15 '11 at 14:09
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.