145 posts
  • Has been part of the Envato Community for over 2 years
  • Located in Austria
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
LovelessDesign says

Hello,

I’ve tried my theme with the standard browser of my android mobile phone (I couldn’t check out a name. It’s just called “Browser”) and my whole jquery Code doesn’t work, even my list menu, which I use for mobile devices instead of the navigation bar.

I also tried Dolphin Browser and Boat Browser where it also doesn’t work. But it works with Opera Mobile Browser and Firefox Mobile Browser.

Does anyone have similar experiences?

I load jquery + my jquery file (functions.js) in the functions.php with this code

wp_deregister_script('jquery');
wp_register_script('jquery','http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', '1.7.1', FALSE); 
wp_register_script('functionsJS', get_template_directory_uri() . '/js/functions.js', array('jquery'), '1.0', TRUE );
wp_enqueue_script('jquery');
wp_enqueue_script('functionsJS');
The functions.js starts with
$(window).load(function () {
I also tried things like
jQuery(document).ready(function($){
203 posts
  • Has sold $40,000+ on Envato Market
  • Made it to the Authors' Hall of Fame
  • Contributed a free file of the month
  • Has been part of the Envato Community for over 2 years
+3 more
ikaruna says

hi,

you say wp_enqueue_script(‘jquery’); Why not name your jquery version “query_custom”. I’m just saying, you could try that.

jayc

203 posts
  • Has sold $40,000+ on Envato Market
  • Made it to the Authors' Hall of Fame
  • Contributed a free file of the month
  • Has been part of the Envato Community for over 2 years
+3 more
ikaruna says

yeah, and if you use a custom version of jQuery ain’t you suppose to use $(document).ready(function(){} ?

145 posts
  • Has been part of the Envato Community for over 2 years
  • Located in Austria
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
LovelessDesign says

thanks for help.

I already figured out the problem but haven’t solved it yet.

In the theme options the user can set some options for Nivoslider which I give from PHP to Javascript in the footer.php:
echo "<script type=\"text/javascript\"><!--
    var nivoslider_speed = \"".ot_get_option('nivoslider_speed')."\";
    var nivoslider_effect = \"".ot_get_option('nivoslider_effect')."\";
    </script>";   ?>
In my JS file I call this variables
    if ( nivoslider_speed == '' ) { nivoslider_speed=4000; }    
    $('#slider').nivoSlider({ 
        effect: nivoslider_effect,
        pauseOnHover: false,
        controlNav: false,
        pauseTime: nivoslider_speed
    });

But the variables don’t have a value with my mobile browser (I tried it with alert).

Any Ideas how I could fix it? I already had problems with that PHP code in the footer.php before with IE when it was located in the header.php: The whole page was empty. That’s why I put it in the footer

203 posts
  • Has sold $40,000+ on Envato Market
  • Made it to the Authors' Hall of Fame
  • Contributed a free file of the month
  • Has been part of the Envato Community for over 2 years
+3 more
ikaruna says

hi,

I dont think you are sending the variable properly, @see documentation around wp_localize_script function.

jayc

203 posts
  • Has sold $40,000+ on Envato Market
  • Made it to the Authors' Hall of Fame
  • Contributed a free file of the month
  • Has been part of the Envato Community for over 2 years
+3 more
ikaruna says

I ‘Think’ you should have something like this:

wp_enqueue_script( 'portfolio_js' ); $js_data = array('POST_TYPE'=>$portfolioScreen['post_type']); wp_localize_script( 'portfolio_js', 'portfolioPHPObj', $js_data );

now you can access the variable in JS like this:

var post_type_name = portfolioPHPObj['POST_TYPE'];

cheers! jayc

2468 posts
  • Has been part of the Envato Community for over 5 years
  • Has sold $100+ on Envato Market
  • Has referred 100+ members
  • Has been a beta tester for an Envato feature
+3 more
digitalimpact says

^ +1

Also, don’t deregister the WP copy of jQuery if building a commercial theme. I believe that is a rejection reason here, just as it is on WordPress.org.

741 posts
  • Had an item featured on Envato Market
  • Won a Most Wanted contest
  • Has been part of the Envato Community for over 5 years
  • Has sold $40,000+ on Envato Market
+4 more
Orbital_Themes says

That’s right. Always use jQuery version that is part of WordPress package or else you can cause incompatibilities with plugins. Also use wp_localize_script() for sending variables to your scripts. This way your code stays clean and you ensure that variables are placed before your script.

3468 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $750,000+ on Envato Market
  • Located in United States
  • Helps us moderate the forums
+10 more
sevenspark Moderator says

^ +1 Also, don’t deregister the WP copy of jQuery if building a commercial theme. I believe that is a rejection reason here, just as it is on WordPress.org.

+50000 that’s what I was about to say

145 posts
  • Has been part of the Envato Community for over 2 years
  • Located in Austria
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
LovelessDesign says

thanks a lot. solved my problem

by
by
by
by
by
by