A little Javascript help

2 views
Skip to first unread message

Phil

unread,
Feb 5, 2012, 9:16:52 PM2/5/12
to Minneapolis St. Paul WordPress User Group
Who had has had luck in getting JS to work well within pages? I'm
integrating some clickable maps and while the good ol' HTML version
works fine, I need to get the JS working. Let me know if you can help
a brother out.

Cheers!

Phil

Susie Nelson

unread,
Feb 5, 2012, 11:11:16 PM2/5/12
to mpls-stpau...@googlegroups.com

I need a clickable map, too.  Thanks for the update.

--
You received this message because you are subscribed to the Google Groups "Minneapolis St. Paul WordPress User Group" group.
To post to this group, send email to mpls-stpau...@googlegroups.com.
To unsubscribe from this group, send email to mpls-stpaul-word...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mpls-stpaul-wordpress?hl=en.

Nick Ciske

unread,
Feb 6, 2012, 10:14:11 AM2/6/12
to Minneapolis St. Paul WordPress User Group
Phil,

Are you using wp_enqueue_script to load your script?
http://codex.wordpress.org/Function_Reference/wp_enqueue_script

Here's another few pointers:
http://www.ericmmartin.com/5-tips-for-using-jquery-with-wordpress/

It might also be that WP uses jQuery in 'no conflict' mode by default
which means the $() syntax doesn't work, and jQuery() must be used
instead. If the script you're using has the $() syntax it won't work
out of the box (see #5 in the second link).

If you can post a specific issue/error we can probably give more
specific feedback.

--Nick

Jeffrey

unread,
Feb 7, 2012, 4:11:24 PM2/7/12
to Minneapolis St. Paul WordPress User Group
You can get rid of the default install of jQuery by putting this in
your functions.php. It will pull in jQuery from Google's CDN, change
the version number as you see fit. It will leave the included version
of jQuery for your admin panel, so that doesn't break. Be cautious of
compatibility with other plugins that may use javascript.

/*
Google CDN jQuery
*/
add_action('init', 'yoursite_jqueryLoader');
function yoursite_jqueryLoader() {
if (!is_admin()) {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/
jquery/1.6.2/jquery.min.js', '', '1.6.2');
}
}

Then use this anywhere before the wp_head() declaration to inject it
into your page.
wp_enqueue_script( 'jquery' );

wp_head(), wp_footer(), and wp_enqueue_script are a super powerful
little combination if you are a heavy javascript user.

Good Luck.

On Feb 6, 9:14 am, Nick Ciske <n...@thoughtrefinery.com> wrote:
> Phil,
>
> Are you using wp_enqueue_script to load your script?http://codex.wordpress.org/Function_Reference/wp_enqueue_script

Phil

unread,
Feb 10, 2012, 8:29:18 AM2/10/12
to Minneapolis St. Paul WordPress User Group
Thanks to all for the input. I'm making headway. Now moving on to
integrating fancy box into the whole thing. What fun!
Reply all
Reply to author
Forward
0 new messages