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.

I want to show a pop up when clicking on an anchor with a specific url. I've tried the following code in the extra calls tab but it doesn't work.

jQuery("a[href='http://www.everytrail.com/view_trip.php?trip_id=2027383']").fancybox({

'transitionIn': 'elastic', 'transitionOut': 'elastic', 'speedIn': 600, 'speedOut': 200, 'type': 'iframe', 'height': 800 });

I assume the problem is in the selector since I have another script where the code beyond the selector is identical to the above, and it works perfectly. I tested the syntax of the selector at W3 schools doing a simple add class test and the syntax appears to be correct.

Any suggestions as to the source of the problem? Syntax, perhaps Fancybox has trouble with certain selectors?

Any advice would be appreciated.

Thanks.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted
jQuery('a[href^="http://www.everytrail.com/view_trip.php?trip_id=2027383"]').fancybox({

Try this.

<script type="text/javascript">

jQuery(document).ready(function($) { jQuery('a[href="http://www.everytrail.com/view_trip.php?trip_id=2027383"]').fancybox({ 'transitionIn': 'elastic', 'transitionOut': 'elastic', 'speedIn': 600, 'speedOut': 200, 'type': 'iframe', 'height': 800 }); });

</script>

I checked on my DEMO, and it works for me

Make sure your site already load jQuery : if there is no jquery.js loaded, use the following code to load

<?php wp_enqueue_script('jquery');?>

add the above code before <?php wp_head(); ?> in header.php //

share|improve this answer
    
Thanks for your response. Are you loading the script in the extra calls tab in fancybox settings or are you loading the script via the functions.php file? If I create the script and load it via functions.php it works. But, if I put the code above in the extra calls tab of the settings then it fails. Note that the example given on the settings page does not indicate a need for (document).ready to be present. I have another script on the extra calls tab and it works correctly. –  dorich Jul 8 '13 at 22:57
    
Do you have firebug setup, or google crome browser - Press F12 to check if you got any Debug console. there check for Javascript error,getfirebug.com/logging. Its more easy to detect the problem and solve it. –  Shahinul Islam Jul 9 '13 at 7:30
    
Can i have the link of your site to check the issue ! –  Shahinul Islam Jul 9 '13 at 7:37
    
Use reflectionsonthetrail.com/bodie Note: I had this working with a script that is loaded in the functions.php file. I disabled that file so that FB will not load. Note: The google pop up is using an externally loaded file. –  dorich Jul 10 '13 at 22:09
    
I have it working. I obviously caused the problem but I've no idea the source of the problem was. Thanks for your help. –  dorich Jul 11 '13 at 0:12
show 1 more comment

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.