145 posts
  • Austria
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 1-2 years
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($){
193 posts
  • Author had a Free File of the Month
  • Sold between 50 000 and 100 000 dollars
  • Has been a member for 2-3 years
  • Exclusive Author
  • Bought between 1 and 9 items
  • Europe
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

193 posts
  • Author had a Free File of the Month
  • Sold between 50 000 and 100 000 dollars
  • Has been a member for 2-3 years
  • Exclusive Author
  • Bought between 1 and 9 items
  • Europe
ikaruna says

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

145 posts
  • Austria
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 1-2 years
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

193 posts
  • Author had a Free File of the Month
  • Sold between 50 000 and 100 000 dollars
  • Has been a member for 2-3 years
  • Exclusive Author
  • Bought between 1 and 9 items
  • Europe
ikaruna says

hi,

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

jayc

193 posts
  • Author had a Free File of the Month
  • Sold between 50 000 and 100 000 dollars
  • Has been a member for 2-3 years
  • Exclusive Author
  • Bought between 1 and 9 items
  • Europe
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

2441 posts
  • Has been a member for 5-6 years
  • Exclusive Author
  • Europe
  • Bought between 10 and 49 items
  • Referred between 100 and 199 users
  • Sold between 100 and 1 000 dollars
  • Envato Studio (Microlancer) Beta Tester
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
  • Has been a member for 5-6 years
  • Sold between 50 000 and 100 000 dollars
  • Exclusive Author
  • Most Wanted Bounty Winner
  • Bought between 50 and 99 items
  • Poland
  • Referred between 10 and 49 users
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.

3424 posts
  • Football Contest Participant/Runner-up
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Community Moderator
  • Bought between 100 and 499 items
  • Referred more than 2000 users
  • Has been a member for 4-5 years
+5 more
sevenspark Volunteer 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
  • Austria
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 1-2 years
LovelessDesign says

thanks a lot. solved my problem

by
by
by
by
by
by